简单apache重定向
如何将www.example.com和example.com中的所有图像重定向到images.example.com 这是我在网上找到的一些代码,但我不太懂,也没有达到预期效果 编辑简单apache重定向,apache,mod-rewrite,Apache,Mod Rewrite,如何将www.example.com和example.com中的所有图像重定向到images.example.com 这是我在网上找到的一些代码,但我不太懂,也没有达到预期效果 编辑 #step 1 redirect ALL images from any domain to images.example.com RewriteCond %{REQUEST_URI} ^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC] RewriteRule ^(.*
#step 1 redirect ALL images from any domain to images.example.com
RewriteCond %{REQUEST_URI} ^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://images.example.com/$1 [L,R=301]
#step 2 redirect non www to www
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#step 3 redirect ALL non images from images.example.com to www.example.com
RewriteCond %{REQUEST_FILENAME} !\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
任何帮助都将不胜感激
谢谢 如果要将所有图像重定向到子域,请执行此操作
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://images.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^images\.example\.com [NC]
RewriteCond %{REQUEST_URI} !^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
好吧,你是想重写到www.example.com而不是image.example.com,就是这样。@Mike Brant:谢谢,我更新了我的代码。。。你能看一下吗?非常感谢!您能否提供有关如何将所有非映像请求从域images.example.com重定向到www.example.com的代码?谢谢此代码正确吗:
RewriteCond%{REQUEST\u FILENAME}!\。(gif | png | jpg | jpeg | jfif | bmp | css | js)$[NC]重写规则^(.*)$http://www.example.com/$1[R=301,L]
我更新了答案。回答后,尽量不要在同一个问题中问多个问题。只要再问一个问题,我们仍然会帮助你。好的,非常感谢!如果您有时间,请看这里: