简体   繁体   English

简单的mod_rewrite无法正常工作

[英]simple mod_rewrite not working

Im kinda new using htaccess and mod rewrite 我有点使用htaccess和mod重写

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 / 1 / forum时,它可以正常工作,但是当我尝试获取这样的长名称时
thread/2/cs-wont-work-for-me 线程/ 2 / CS-不会工作换我

The htaccess gets me a error 404.. htaccess提示我错误404。

And my links i change so (spaces) gets - and åäö gets aao 我的链接改变了,所以(空格)得到了-åäö得到了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. 只是发表评论,告诉我,那我可以再给你一点点。

thread/2/cs-wont-work-for-me is not matched because you only check for alpha numeric characters ( [A-Za-z0-9]+ ). thread/2/cs-wont-work-for-me不匹配,因为您仅检查字母数字字符( [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. 附带一提,我真的可以推荐htaccess测试仪来调试此类问题。

You can use as 您可以用作

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

Does not check the last sequence of string of specific pattern 不检查特定模式的字符串的最后一个序列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM