我的两个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]
如果网址包含下载(如下所示:mydomain.com/download/9),则第一条规则应该将此请求重写为download.php?id = 9。但事实并非如此。
var_dump($ _ GET)显示以下内容:
array(2) { ["c"]=> string(4) "view" ["misc"]=> string(9) "index.php" } index.php
有什么想法吗?
答案 0 :(得分:1)
好的,我解决了这个问题。
# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteEngine On
Options +FollowSymlinks
Options -Indexes
RewriteBase /test/download/
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?c=view&misc=$1 [B]
谢谢你们! :)
答案 1 :(得分:0)
问题不在于规则。它在这里工作。
http://wingsoflol.org/download/9
我的download.php包含
Hi!
<br>Id = <?
echo $_GET['id'];
?>
,规则是
RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]
你确定RewriteBase应该是/ test /?