Mod_rewrite问题

时间:2011-02-23 18:29:31

标签: .htaccess

可以使用mod_rewrite和htaccess重写我的网址,用户可以输入:

http://www.mainsite.com/12345

服务器将翻译为:

http://www.mainsite.com/index.php?ID=12345

通过尝试从所有页面中删除文件扩展名(删除.php),它会发生冲突并导致永无止境的重定向:

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php$ $1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-zA-Z]+)$ index.html?ID=$1 [QSA,NC,L,R]
</IfModule>

1 个答案:

答案 0 :(得分:1)

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ index.php?ID=$1