网址重写帮助

时间:2009-11-02 11:29:43

标签: php rewrite

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule ^(.*)$ index.php?q=$1 [L]

这应该重写任何url到index.php?q = {url},它正在工作。无论如何,http://www.domain.com/只显示一个空白页面。我怎样才能重写/到index.php? (http://www.domain.co.il/index.php不显示空白页面。)

BTW:这段代码重定向而不是重写,为什么会这样?

感谢。

2 个答案:

答案 0 :(得分:2)

您需要在DirectoryIndex文件中设置.htaccess

DirectoryIndex index.php

答案 1 :(得分:0)

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ index.php?q=$1 [L]