Trying to determine why only the last redirect returns a "Too Many Redirects" error when visiting the page. If I add anymore after the last one they all get the same error when visiting the pages.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myhrc.biz$ [OR]
RewriteCond %{HTTP_HOST} ^www.myhrc.biz$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofcontractor.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofcontractor.com$ [OR]
RewriteCond %{HTTP_HOST} ^bestroofertx.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.bestroofertx.com$ [OR]
RewriteCond %{HTTP_HOST} ^roofingcompanyhoustontexas.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.roofingcompanyhoustontexas.com$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingreviews.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingreviews.com$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.co$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.co$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.net$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.info$ [OR]
RewriteCond %{HTTP_HOST} ^www.houstonroofingonline.info$ [OR]
RewriteCond %{HTTP_HOST} ^houstonroofingonline.com$
RewriteRule (.*)$ http://www.houstonroofingonline.com/$1 [R=301,L]
ErrorDocument 404 http://www.houstonroofingonline.com/404.html
RedirectMatch 301 ^/residential http://www.houstonroofingonline.com/residential-roofing-houston.html
RedirectMatch 301 ^/about-us http://www.houstonroofingonline.com/houston-roofing-company.html
RedirectMatch 301 ^/residential/insurance-claims http://www.houstonroofingonline.com/roof-insurance-claims-houston.html
RedirectMatch 301 ^/residential/free-roof http://www.houstonroofingonline.com/free-roof-insurance-claim.html
RedirectMatch 301 ^/residential/storm-damage http://www.houstonroofingonline.com/storm-damage-roof-repair-houston.html
RedirectMatch 301 ^/residential/roof-inspection http://www.houstonroofingonline.com/free-roof-inspection-houston.html
RedirectMatch 301 ^/residential/roof-repair http://www.houstonroofingonline.com/roof-repair-houston.html
RedirectMatch 301 ^/commercial http://www.houstonroofingonline.com/commercial-roofing-houston.html
RedirectMatch 301 ^/contact-us http://www.houstonroofingonline.com/contact.html
RedirectMatch 301 ^/blog http://www.houstonroofingonline.com/houston-roofing-blog.html
RedirectMatch 301 ^/roofing-system-complexities http://www.houstonroofingonline.com/roofing-systems.html
RedirectMatch 301 ^/how-to-select-roof http://www.houstonroofingonline.com/how-to-select-a-roof.html
RedirectMatch 301 ^/your-roof-as-a-selling-tool http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html
Your last Redirect is causing a Redirect Loop error /Too many Redirect error.
Let's see why this is happening :
RedirectMatch 301 ^/your-roof-as-a-selling-tool http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html
Actually , The pattern and the destination path of your RedirectMatch are identical.
Pattern : ^/your-roof-as-a-selling-tool*
Destination url
: http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html
When you request example.com/your-roof-as-a-selling-tool your RedirectMatch redirects the url to
http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html in the first round. And in the second round http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html matches the pattern and Redirects to itself.
To avoid this multiple redirect behavior you need to fix the pattern so it doesn't match the destination path. Simply add a regex end of string character $ at the end so that it can only match a specific uri /your-roof-as-a-selling-tool not ...tool.html .
RedirectMatch 301 ^/your-roof-as-a-selling-tool$ http://www.houstonroofingonline.com/your-roof-as-a-selling-tool.html
Related
How do I phrase a 301 redirect that is effectively 'anything else'? In other words I have a specific list of pages to redirect but I simply want anything that is not specifically redirected to go to the home page
The line: RewriteCond %{REQUEST_URI} !/$ stops the infinite redirect loop from root to root.
RedirectMatch 301 ^pag1.html$ /new_pag1.html
RedirectMatch 301 ^pag2.html$ /new_pag2.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !/pag1.html$
RewriteCond %{REQUEST_URI} !/new_pag1.html$
RewriteCond %{REQUEST_URI} !/pag2.html$
RewriteCond %{REQUEST_URI} !/new_pag2.html$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ / [R=301,L]
Ok, so I've got a stack of htaccess redirects from one domain to another, which for the most part works fine. However, this particular link isn't working:
http://giccampers.com.au/general-trailers/tipper-trailer/
It should take people to this website:
http://blackseriescampertrailers.com.au/
If you go to the main domain of http://giccampers.com.au/ it redirects fine. But I can't seem to get any of the other pages to redirect from that domain.
Here's what I've got (I didn't set these up, btw):
RewriteCond %{HTTP_HOST} ^giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^giccampers\.com\.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.giccampers\.com\.au$
RewriteRule ^/?$ "http\:\/\/www\.blackseriescampertrailers\.com\.au\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^www.giccampers.com.au [NC]
RewriteRule ^(.*)$ http://blackseriescampertrailers.com.au/$1 [L,R=301]
redirect 301 /general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/
Any help would be great!
use this
RedirectMatch 301 http://giccampers.com.au/general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/
RedirectMatch 301 /general-trailers/tipper-trailer/ http://blackseriescampertrailers.com.au/
or
RedirectMatch 301 /tipper-trailer$ http://blackseriescampertrailers.com.au/
or
RedirectMatch 301 /general-trailers/tipper-trailer(.*)http://blackseriescampertrailers.com.au/
I have a list of specific pages I redirect with the "Redirect 301" rule.
Now I'm looking to redirect all the other pages I didn't specificaly mention in this list.
How can I do that?
.htaccess:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)?parachute\-club\-cannes\.com$ [NC]
RewriteRule .* http://parachute-club-cannes.com%{REQUEST_URI} [R=301,L]
# Same for HTTPS:
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\.parachute-club-cannes\.com$ [NC]
RewriteRule ^ http://parachute-club-cannes.com%{REQUEST_URI} [R=301,L]
# 301 Redirect URLs.
Redirect 301 /www.pccannes.com http://www.parachute-club-cannes.com
I'm not sure if what I want to achieve is even possible via .htaccess, I have trawled Google without any luck.
I have a pile of redirects to apply to a multi-store website which means that two domains will share the same .htaccess file. The problem that I have is that the redirects for each domain are conflicting with each other.
Is it possible set up the equivalent of a php 'if' statement within the .htaccess file without adding a condition before each redirect?
<If domain = http://www.example-1.com>
RedirectMatch 301 ^/en/1-2-drive-torque http://www.example-1.com/90-britool-expert-torque-wrenches
RedirectMatch 301 ^/en/10-Britool http://www.example-1.com/24-britool-expert-spanners
RedirectMatch 301 ^/en/11-Britool http://www.example-1.com/78-britool-expert-combination-spanners
RedirectMatch 301 ^/en/12-Britool http://www.example-1.com/77-britool-expert-ratchet-spanners
RedirectMatch 301 ^/en/13-Britool http://www.example-1.com/79-britool-expert-open-end-spanners
etc...
</If>
<If domain = http://www.example-2.com>
RedirectMatch 301 ^/en/1-2-drive-torque http://www.example-2.com/390-britool-expert-torque-wrenches
RedirectMatch 301 ^/en/10-Britool http://www.example-2.com/624-britool-expert-spanners
RedirectMatch 301 ^/en/11-Britool http://www.example-2.com/478-britool-expert-combination-spanners
RedirectMatch 301 ^/en/12-Britool http://www.example-2.com/677-britool-expert-ratchet-spanners
RedirectMatch 301 ^/en/13-Britool http://www.example-2.com/779-britool-expert-open-end-spanners
etc...
</If>
Any help or advice will be very much appreciated
You'll need to use mod_rewrite for this instead and use the %{HTTP_HOST}. Unfortunately, there's no way to create "if" containers like you have in your example. You'll need to duplicate the condition each time:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example-1\.com$ [NC]
RewriteRule ^en/1-2-drive-torque /90-britool-expert-torque-wrenches [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-1\.com$ [NC]
RewriteRule ^en/10-Britool /24-britool-expert-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-1\.com$ [NC]
RewriteRule ^en/11-Britool /78-britool-expert-combination-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-1\.com$ [NC]
RewriteRule ^en/12-Britool /77-britool-expert-ratchet-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-1\.com$ [NC]
RewriteRule ^en/13-Britool /79-britool-expert-open-end-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-2\.com$ [NC]
RewriteRule ^en/1-2-drive-torque /390-britool-expert-torque-wrenches [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-2\.com$ [NC]
RewriteRule ^en/10-Britool /624-britool-expert-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-2\.com$ [NC]
RewriteRule ^en/11-Britool /478-britool-expert-combination-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-2\.com$ [NC]
RewriteRule ^en/12-Britool /677-britool-expert-ratchet-spanners [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?example-2\.com$ [NC]
RewriteRule ^en/13-Britool /779-britool-expert-open-end-spanners [L,R=301]
Can someone help? For some reason the 301 redirects are not working.... The rewrite conditons format my urls by removing the extensions, so not sure if I need to remove the extensions from the 301 statements or not.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.beingchildren\.org$ [NC]
RewriteRule ^(.*) http://www.beingchildren.org/$1 [L,R=301]
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.htm[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(.+?)/?$ /$1.htm [L]
errordocument 404 /404.php
Redirect 301 /Blog/2012-12-25-Christmas-Presents.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-03-29-Mixed-Slum-Photos.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-05-14-Monthly-Slum-Visits-1.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-06-12-Panjim-Monsoon.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-06-15-Margao-Charity-Donations-1.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-09-08-Margao-Ganesh-Celebrations.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Blog/2013-09-08-Margao-Ganesh-Holidays.htm http://www.beingchildren.org/Children-Charity-Blog
Redirect 301 /Charity.htm http://www.beingchildren.org
Redirect 301 /Children-Charity-Pictures.htm http://www.beingchildren.org/Children-Charity-Blog
It is because of 2 issues:
301 rules are at the bottom after .htm is removed
mixing of mod_alias and mod_rewrite rules
Try this code instead:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.beingchildren\.org$ [NC]
RewriteRule ^(.*) http://www.beingchildren.org/$1 [L,R=301]
RewriteRule ^Blog/2012-12-25-Christmas-Presents\.htm$ http://www.beingchildren.org/Children-Charity-Blog [L,R=301,NC]
RewriteRule ^Blog/2013-03-29-Mixed-Slum-Photos\.htm$ http://www.beingchildren.org/Children-Charity-Blog [L,R=301,NC]
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.htm[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.htm -f
RewriteRule ^(.+?)/?$ /$1.htm [L]
PS: I have converted only top 2 of your 301 rules. Once those are working you can similarly convert rest.