0

私は .htaccess にこのコードを持っています:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(css|gif|ico|jpg|js|png|swf|txt)$

# If empty subdomain, replace with "www"
RewriteCond %{HTTP_HOST} ^example.com$ 
RewriteRule ^(.*) http://www.example.com/$1 [QSA,L,R=301]

# If subdomain isn't empty and not "www", redirect to "folder"
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$
RewriteRule (.*) http://www.example.com/%1/$1 [QSA,R=301]

#PAGES REDIRECTION
RewriteRule ^(.*)/register/ /index.php?sub=$1&page=register
RewriteRule ^(.*)/register  /index.php?sub=$1&page=register
RewriteRule ^(.*)/lostpass/ /index.php?sub=$1&page=lostpass
RewriteRule ^(.*)/lostpass  /index.php?sub=$1&page=lostpass
...

(ワイルドカード サブドメインのルールは既に導入され、機能しています)

http://test.example.comを参照すると、 http://www.example.com/testに正しくリダイレ​​クトされますが、 http://test.example.com/registerを参照しようとすると、実際にはリダイレクトされますhttp://www.example.com/test/index.php?sub=http://www.example.com/test&page=registerにリダイレクトし、 http://www.example.com/test/registerにリダイレクトする必要があります

ここで何が間違っていますか?前もって感謝します!

4

1 に答える 1

0

L最初のリダイレクト ルールと同様に、2 番目のリダイレクト ルールにフラグを追加してみてください。

RewriteRule (.*) http://www.example.com/%1/$1 [QSA,R=301,L]

書き換えられた URI が次のルールに渡されているようです。

RewriteCondまた、最初の 2 つは正しい場所にあるとは思いません。

于 2013-01-08T01:07:45.030 に答える