【发布时间】:2011-06-28 21:27:01
【问题描述】:
我正在尝试使用 mod_rewrite 来美化网站上的 URL。但这似乎不起作用。我想要以下网址:
改写为:
http://mydomain.com/index.php?t=test
我的 .htaccess 文件如下所示:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?t=$1 [L]
</IfModule>
但它似乎不起作用。
mod_rewrite 肯定是启用的,因为以下简单规则确实会将站点重定向到 example.com:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ http://example.com/?
</IfModule>
我的网站由 GoDaddy 托管,如果这有所作为的话。该站点还设置为主站点的子域。
【问题讨论】:
-
解释一下
But it does not seem to be working.是什么意思@到底发生了什么? -
如果你把那些
RewriteConds拿出来怎么办?有必要吗? -
RewriteConds 是必要的,在这种情况下它不会重写现有文件/文件夹
标签: php apache mod-rewrite friendly-url