Forum Moderators: Robert Charlton & goodroi
RewriteRule ^(.*)\-tag\.html&tagtype=contentType$ http://www.example.com/content/contentType/tag/$1/ [R=301,L] *FIXED THIS PART* [edited by: realmaverick at 10:07 pm (utc) on Mar 11, 2012]
example.com/example-tag,html&tagtype=contentType
RewriteRule ^(.*)-tag(.*)\.html&tagtype=widget http://www.example.com/widget/widgets/tag/$1/ [R=301,L]
which works. [edited by: realmaverick at 10:30 pm (utc) on Mar 11, 2012]
Never mass redirect URLs for multiple removed pages to a single page.
You'll have your site flagged for "soft 404 errors" and that's a bad thing.
That's not what I'm doing.
RewriteRule ^(.*)-tag(.*)\.html&tagtype=widget http://www.example.com/widget/widgets/tag/$1/ [R=301,L]
which works.
the first (.*) is to catch all tags so for example madonna-tag and the second is to catch a number, that sometimes appears after the tag i.e tag123.html
It then redirects to http://www.example.come/widget/widgets/tag/madonna/
There is only one Madonna tag, it may or may not contain a number. Some of the tags do an others don't. There aren't multiple versions of each though. The number is unique to the tag.
RewriteRule ^([A-Za-z0-9]+)-tag([0-9]*)\.html&tagtype=widget http://www.example.com/widget/widgets/tag/$1/ [R=301,L]
http://www.example.com/example-tag.html&tagtype=widget http://www.example/widget/widgets/tag/example/ lucy24 wrote:
.* >> Server dutifully captures the entire request.
This is false. If you have a regex of the form "^(.*)-tag" and match it against the string "foo-tag bar-tag", the captured subpattern will contain "foo-tag bar", not "foo-tag bar-tag".
I'm still interested in how I'd make this a RewriteCond
This is false. If you have a regex of the form "^(.*)-tag" and match it against the string "foo-tag bar-tag", the captured subpattern will contain "foo-tag bar", not "foo-tag bar-tag".
lucy24 wrote:
You've misunderstood. The Regular Expression first captures all the way to the end. It then has to backtrack, spitting out part of its original capture, until it finds the last occurrence of -tag.
realmaverick wrote:
Hi g1smd, I've added the plus with success, however I can't seem to pickup the hyphen in *blue-widget*-tag.html
RewriteCond %{QUERY_STRING} !.