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 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动