我环顾四周寻找答案,没有运气。需要.htaccess重写规则建议
我想要做的就是更换
http://localhost/mysite/superv/something
与
http://localhost/mysite/superv/?p=something
这是我从昨天起想出了最佳配方:
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^(superv/)([^\?/]+)$ $1\?p=$2 [NC]
但它不工作。
我觉得“RewriteBase”啄无关的问题,因为这条线的工作就像一个魅力:
RewriteRule ^(javascripts/main\.js)$ $1\.php [NC]
编辑:右键Rekire,这是一个错误,而复制和粘贴代码。我现在解决了这个问题。
EDIT2:下面是出现在Apache日志错误:
[Tue Mar 20 20:26:01 2012] [error] [client 127.0.0.1]
Request exceeded the limit of 10 internal redirects due to probable configuration error.
Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
我猜问题是 “循环”,我引述:
Looping occurs when the target of a rewrite rule matches the pattern.
This results in an infinite loop of rewrites
那么,如果你写入你的'RewriteRule'“superv”,但你试图用“admin”来管理一个URL,那么这是行不通的。 – rekire 2012-03-20 17:31:47
请注意,评论者不会被通知编辑。我想知道你正试图将用户重定向到一个php文件的路径。这可能是你的问题。 – rekire 2012-03-20 18:14:01
请勿在替换字符串中转义字符,例如'$ 1吗?P = $ 2'。另外你为什么[内部]重定向'http:// localhost/mysite/javascripts/main.js'到'http:// localhost/mysite/javascripts/main.js.php'? – TerryE 2012-03-20 20:36:57