301 Redirect going to Long URL - why?
Moderator: General Moderators
Re: 301 Redirect going to Long URL - why?
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?
You may also find htaccess tester to be useful.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 301 Redirect going to Long URL - why?
Iv'e got over 600 of these to do.
Can it be done like this?
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??
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]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: 301 Redirect going to Long URL - why?
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?
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]-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 301 Redirect going to Long URL - why?
[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?
It doesn't like // in the rule.
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]Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 301 Redirect going to Long URL - why?
Code: Select all
RewriteRule ^subcateg\/\/CLEARANCE-SALE\/\/CLOTHING/?$ /subcateg/56/CLEARANCE-SALE/66/CLOTHING [QSA]Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: 301 Redirect going to Long URL - why?
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]Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.