douhunbei0166 2014-02-11 13:27
浏览 36


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

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:


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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 安卓13,动态广播无法接受
  • ¥50 docker运行容器端口如何映射(不重启服务、不重建容器)
  • ¥30 使用XPath爬取模拟图书馆网站的数据
  • ¥50 基于TwinCAT3实现力传感器的实时读取
  • ¥20 python求解八元一次不定方程,无数解中随机输出几组即可(相关搜索:用python)
  • ¥50 libreoffice导出PPTX到PDF中的错误换行问题
  • ¥15 python实现网页视频下载
  • ¥15 如何通过深度图获得物体的完整、正确点云?
  • ¥15 有没有操作系统适用白丁的经典的书籍,如何解决?(标签-学习)
  • ¥15 Catia V5 R20 64位 安装过程中选择orbix配置创建套接字失败