0

我有以下网址

http://www.localhost/me/me/username

我想将其重写为

http://www.localhost/me/username

任何mod重写专家可以给我一些建议吗?以下是我当前的mod重写

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
4

1 回答 1

0

你可以在 /.htaccess 中试试这个:

RewriteEngine On
RewriteRule ^(me/){2,}username$ /$1username [R=301,L]

它这样做:

http://www.localhost/me/me/username => http://www.localhost/me/username
http://www.localhost/me/me/me/me/username => http://www.localhost/me/username

或者你似乎想要这个:

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

RewriteRule ^(me/){2,}username$ /$1username [R=301,L]

后者将这样做:

http://localhost/me/username => http://www.localhost/me/username
http://localhost/me/me/username => http://www.localhost/me/username
http://www.localhost/me/me/me/me/username => http://www.localhost/me/username
于 2013-11-10T15:48:50.033 回答