.htaccess (mod_rewrite) 出现问题。 RewriteRule 无法正常工作
我的两个重写规则有问题。
.htaccess:
# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteEngine On
Options +FollowSymlinks
Options -Indexes
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
RewriteRule ^(.*)$ index.php?c=view&misc=$1 [B]
如果 url 包含 download(有些像这样:mydomain.com/download/9),则第一条规则应将此请求重定向为 download.php?id=9。但事实并非如此。
var_dump($_GET) 显示以下内容:
array(2) { ["c"]=> string(4) "view" ["misc"]=> string(9) "index.php" } index.php
有什么想法吗?
I have a problem with my two RewriteRules.
.htaccess:
# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteEngine On
Options +FollowSymlinks
Options -Indexes
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
RewriteRule ^(.*)$ index.php?c=view&misc=$1 [B]
If the url contains download (some like this: mydomain.com/download/9) the first rule should redict this request to download.php?id=9. But it doesn't.
var_dump($_GET) shows the following:
array(2) { ["c"]=> string(4) "view" ["misc"]=> string(9) "index.php" } index.php
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好的,我解决了问题。
谢谢你们! :)
Ok, I solved the problem.
Thanks guys! :)
问题不在于规则。它在这里工作。
http://wingsoflol.org/download/9
我的 download.php 包含
,规则是
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
您确定 RewriteBase 应该是 /test/ 吗?
The problem is not with the rule. It works here.
http://wingsoflol.org/download/9
My download.php contains
and the rule is
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
Are you sure the RewriteBase should be /test/ ?