简单的 apache 重定向
Simple apache redirect
如何将所有图像从 www.example.com 和 example.com 重定向到图像。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 ^(.*)$ http://images.example.com/ [L,R=301]
#step 2 redirect non www to www
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/ [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/ [L,R=301]
任何帮助将不胜感激!
谢谢!
如果您想将所有图像重定向到子域,请执行此操作。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://images.example.com/ [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/ [L,R=301]
如何将所有图像从 www.example.com 和 example.com 重定向到图像。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 ^(.*)$ http://images.example.com/ [L,R=301]
#step 2 redirect non www to www
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/ [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/ [L,R=301]
任何帮助将不胜感激!
谢谢!
如果您想将所有图像重定向到子域,请执行此操作。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.+)\.(gif|png|jpg|jpeg|jfif|bmp|css|js)$ [NC]
RewriteRule ^(.*)$ http://images.example.com/ [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/ [L,R=301]