mardi 30 août 2016

htaccess - Change RedirectPermanent Redirect to 404 With Minimum Redirects

The top section of the .htaccess file on our website look like below:

RewriteEngine On
RewriteBase /

RedirectPermanent ^/en-uk-ca/(.*)$ /
RedirectPermanent ^/en/uk-ca/(.*)$ /
RedirectPermanent ^/uk-ca/(.*)$ /
RedirectPermanent ^(.*)\.html$ /
RedirectPermanent ^/life/(.*)$ /
RedirectPermanent ^/life-graph/(.*)$ /


RewriteCond %{HTTP_HOST} ^111\.111\.111\.11
RewriteRule (.*) https://domain.com/$1 [R=301,L]

RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* ? [F,L]

RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ https://domain.com/$1 [L,R=301]

RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}  [R,L]

RewriteCond %{REQUEST_URI}  !\.(php|html?|svg|txt|xml|js|ico|png|jpeg|jpg|gif)$
RewriteRule ^(.*)([^/])$ https://%{HTTP_HOST}/$1$2/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php

I want to put 404 instead of 302 for RedirectPermanent links such as ^/en-uk-ca/, /life-graph/, etc, and also redirect the www.domain.com to domain.com. Is the order of the redirects correct? Thanks.




Aucun commentaire:

Enregistrer un commentaire