Using Regex for redirects
I have inherited a couple sites with 100+ pages of content I would like to convert them to Harmony, but my client is very concerned about not messing the content that has already been indexed by Google. So I will need to create many redirects...maybe.
For many of pages I should be able to use a regex. If the path
is the same minus the .html, but I have failed at my attempts so
far.
I think I want to do:
\/(specifications).html -> /(\1)/
but that doesn't seem to work.
What are your thoughts?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Steve Smith on 03 May, 2010 04:13 PM
Likely, your regix is going to look like this: \/(.*)\.html -> /\1/
The . character represents any character in regex, so that should be pretty greedy, but convert any /path/to/whatever.html file to /path/to/whatever/
3 Posted by John Nunemaker on 03 May, 2010 04:17 PM
I don't know if it works with the slash at the beginning. Try removing that
(\/) as well. I need to make it so it works with or without the slash.
4 Posted by Torey Heinz on 03 May, 2010 05:41 PM
OK, my regex above is totally wrong, I can admit it ... I won't even edit it to save face :)
Here is what worked
(.*)\.html -> /\1/Support Staff 5 Posted by Steve Smith on 03 May, 2010 06:39 PM
You're close on your first one. Try this:
(.*)\html -> \1/
Torey Heinz closed this discussion on 19 Jul, 2010 11:15 PM.