URL_Rewrite正在重定向并附加WWW

时间:2013-03-17 12:19:04

标签: apache mod-rewrite redirect

也许我只是完全遗漏了一些东西,但我有以下重写规则:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NE,L]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,NE,L]

RewriteCond %{REQUEST_URI} !wp-content/uploads/_original [NC]
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule !^wp-content/uploads/[A-Z] - [S=26]
RewriteRule ^wp-content/uploads/A([^/]+)\.(png|jpg|bmp|gif)$ wp-content/uploads/_original/a/A$1.$2 [R=301,NE,L]
#
# Removed extra rules 

基本上我输入的网址如下:

wp-content/uploads/b35d7cc8114012715cca8e6c8266b63d.jpg

它最终会重定向到正确的文件:

wp-content/uploads/_original/b/b35d7cc8114012715cca8e6c8266b63d.jpg

但根据萤火虫的说法,它的处理如下:

Request for: wp-content/uploads/b35d7cc8114012715cca8e6c8266b63d.jpg
Location: http://www.domainname.com/wp-content/uploads/_original/b/baby_soft_hands_600x450.jpg

由于我将WWW请求重定向到基本域,因此它会进行另一次重定向。为什么要将WWW附加到此初始重定向?

感谢您的帮助。

0 个答案:

没有答案