0

嗨,我有以下类似的东西,一切正常,直到我尝试添加“www”,如果它不存在,我得到如下所示:

来源:http ://domain.net/welcome/

重写:http ://www.domain.net//index.php/?request=welcome

php_value register_globals "on"
RewriteEngine on


RewriteRule ^(.+)/$ /index.php?request=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteCond %{HTTP_HOST} ^domain.net$
RewriteRule (.*) http://www.domain.net/$1 [R=301]

ErrorDocument 404 /404.php?request=$1
4

1 回答 1

0

Try moving your redirect rules above the rest of your rules and add the [L] flag:

php_value register_globals "on"
RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain.net$
RewriteRule (.*) http://www.domain.net/$1 [R=301,L]

RewriteRule ^(.+)/$ /index.php?request=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

ErrorDocument 404 /404.php?request=$1
于 2012-07-29T19:55:35.203 回答