douhunbei0166 2014-02-11 13:27
浏览 36
已采纳

简单的mod_rewrite不起作用

Im kinda new using htaccess and mod rewrite

I got every link to work as i want, but i have a problem when im trying to change the link for the forum everything goes kinda to hell..

This is my code

RewriteRule ^thread/([0-9]+)/([A-Za-z0-9]+)$ sidor/forum/showthread.php?threadID=$1&name=$2 [L]

When i try to get thread/1/forum it works perfectly but when i try to get a longer name like this
thread/2/cs-wont-work-for-me

The htaccess gets me a error 404..

And my links i change so (spaces) gets - and åäö gets aao

Anyone knows what the problem is?

Do you need more code? just post a comment and tell me that then i can try to give you a little more.

  • 写回答

2条回答 默认 最新

  • dougan1884 2014-02-11 13:29
    关注

    thread/2/cs-wont-work-for-me is not matched because you only check for alpha numeric characters ([A-Za-z0-9]+). Include dashes and any other characters you want to match to your regex. This should do what you want:

    ^thread/([0-9]+)/([A-Za-z0-9\-ÅÄÖåäö]+)$
    

    As a sidenote, I can really recommend htaccess tester to debug issues like this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击