Page 2 of 2
Re: 301 Redirect going to Long URL - why?
Posted: Wed Aug 27, 2014 9:45 am
by jdhmtl
Both rewrite conditions need to be met in order for the rule to be applied. The first checks the page requested, the second checks the query string (?url=etc) and then the redirect triggers when both are met. You can add regex into the second condition to make it apply to a group of query strings rather than a specific one if need be.
Re: 301 Redirect going to Long URL - why?
Posted: Wed Aug 27, 2014 9:48 am
by jdhmtl
You may also find
htaccess tester to be useful.
Re: 301 Redirect going to Long URL - why?
Posted: Wed Aug 27, 2014 11:28 am
by simonmlewis
Iv'e got over 600 of these to do.
Can it be done like this?
Code: Select all
RewriteCond %{REQUEST_URI} ip_mobilehome.php
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/512/HOLD/312/HOLD/372/R9-P90S/?$
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/242/HOLD/312/HOLD/372/R9-P90S/?$
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/335/HOLD/312/HOLD/372/R9-P90S/?$
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/664/HOLD/312/HOLD/372/R9-P90S/?$
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/666/HOLD/312/HOLD/372/R9-P90S/?$
RewriteRule (.*) index.php?page=selectpage&menu=home [L]
So I can use Excel to strip back the URL and get it done way faster, or do you literally have to do it three rows at a time??
Re: 301 Redirect going to Long URL - why?
Posted: Wed Aug 27, 2014 11:31 am
by jdhmtl
That's definitely not going to work as all rewrite conditions must pass before the rewrite rule fires. Why not use regex instead of copying 600 lines?
Re: 301 Redirect going to Long URL - why?
Posted: Wed Aug 27, 2014 11:34 am
by jdhmtl
Something like this should do what you need. Swap out regex patterns for static values if/as needed.
Code: Select all
RewriteCond %{REQUEST_URI} ip_mobilehome.php
RewriteCond %{QUERY_STRING} ^url=http://www.site.co.uk/product/[\d]{3}/HOLD/[\d]{3}/HOLD/[\d]{3}/R9-P90S/?$
RewriteRule (.*) index.php?page=selectpage&menu=home [L]
Re: 301 Redirect going to Long URL - why?
Posted: Wed Dec 10, 2014 4:15 am
by simonmlewis
[text]/subcateg//CLEARANCE-SALE//CLOTHING/[/text]
We are getting "NOT FOUND" errors for these URLs, quite rightly, because there are missing numbers in there.
It seems to be caching old links that were wrong, but have since left the web site, but as they are cached, they still error on the Google Webmasters.
So how do I do one of these for that?
Code: Select all
RewriteRule ^subcateg//CLEARANCE-SALE//CLOTHING/?$ /subcateg/56/CLEARANCE-SALE/66/CLOTHING [QSA]
It doesn't like // in the rule.
Re: 301 Redirect going to Long URL - why?
Posted: Wed Dec 10, 2014 6:49 am
by Celauran
Escape the slashes
Re: 301 Redirect going to Long URL - why?
Posted: Wed Dec 10, 2014 8:06 am
by simonmlewis
Code: Select all
RewriteRule ^subcateg\/\/CLEARANCE-SALE\/\/CLOTHING/?$ /subcateg/56/CLEARANCE-SALE/66/CLOTHING [QSA]
Like this you mean?
Re: 301 Redirect going to Long URL - why?
Posted: Wed Dec 10, 2014 10:00 am
by simonmlewis
Also, if I want to permanently tell googlebots that a URL is now *this* URL, is it best done in the way I have written it, or like this:
Code: Select all
RewriteRule ^/subcateg/4/TACTICAL-FIGURE-SETS-1:6/22/FBI-FIGURES/?$ /subcateg/4/TACTICAL-FIGURE-SETS-1:6/224/FBI-FIGURES/ [R=301,L]