开发者

Problem with .htaccess (mod_rewrite). RewriteRule's doens't work correctly

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?


Ok, I solved the problem.

# 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]

Thanks guys! :)


The problem is not with the rule. It works here.

http://wingsoflol.org/download/9

My download.php contains

Hi!
<br>Id = <?
echo $_GET['id'];
?>

and the rule is

RewriteRule ^download/([0-9]+)$ download.php?id=$1 [L]

Are you sure the RewriteBase should be /test/ ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜