配置mod_rewrite问题

时间:2014-01-13 16:17:03

标签: regex .htaccess mod-rewrite

我的htaccess中有以下内容:

DirectoryIndex index.py
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)$ index.py?id=$1 [L]
RewriteCond %{THE_REQUEST} /index\.py [NC]
RewriteRule ^(.*?)index\.py$ /$1 [L,R=302,NC,NE]

第一条规则派人寻找

mydomain.com/<digits>

到mydomain.com/index.php?id=,第二条规则修复了index.py中的hrefs。 但是当我添加

RewriteBase /
RewriteRule ^([^0-9]+)$ index.py [L]

为了让任何请求不仅仅是数字的人转到index.py,index.py中的div只是有点消失。有什么问题?

1 个答案:

答案 0 :(得分:1)

可能是因为您正在将所有内容重写为index.py,包括样式表或脚本或其他内容。尝试将规则更改为:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^0-9]+)$ index.py [L]