不要重定向某个文件

时间:2015-03-26 17:52:56

标签: .htaccess redirect

我有以下htaccess文件。我不想在某个文件上执行从https到http的重定向。我怎么能做到这一点?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^intranet.spectrumasa.com$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=302,L]

RewriteCond %{HTTP_HOST} ^www.asb.com.au$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/ [R=301,L]


RewriteCond %{HTTP_HOST} ^www\.spectrum-geopex\.com\.eg$ [NC]
RewriteRule ^(.*)$ http://www.spectrumgeo.com/spectrum-geopex [R=301,L]

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

我想通过https http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg

仅访问以下内容

2 个答案:

答案 0 :(得分:1)

为您的规则添加条件:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/Spectrum_logo_email-171w\.jpg$
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

答案 1 :(得分:0)

https://重定向到http://,您可以选择一些复杂的内容,但是您可以通过此方法在单个文件上完成一个简单的redirect

RewriteEngine

Redirect http://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg https://www.spectrumgeo.com/wp-content/uploads/Spectrum_logo_email-171w.jpg

这将解决仅通过https://

访问您的上述网址的问题