This is a story about resolved problem - syntax issue - simple stuff as in most of cases.
It happened that the folder and file names within it had to be renamed.
As the file names have a pattern, I thought that two lines should do it, rather than one line for each page.
Basically a folder is being renamed from /a1-a2-a3/ to /a1-a2/, and files from /something-a2-a3.html to /something-a2.html
I already have an entry that rewrites all subfolder index.html files to a subfolder itself, so any request for index.html file goes to / of the page.
Based on the above, I came up with two lines of 301:
RewriteRule ^a1-a2-a3/$ http://www.example.com/a1-a2/ [R=301,L]
RewriteRule ^a1-a2-a3/(*.)-a2-a3\.html$ http://www.example.com/a1-a2/$1-a2.html [R=301,L]
I got 500...
I tested each line separately, and got that only the second one causes 500.
Then I searched and came to another post at WW, and found this:
RedirectMatch 301 ^/the_old_([^.]+)\.htm$ http://example.com/the-new-$1.htm
I decided to go step by step, so I left RewriteRule, but replaced my (*.) with ([^.]+) - and it worked.
Then, I wanted to double check, and finally found that my only problem was the syntax as (*.) should actually be (.*)
Arghhh... always check the code again and again.
Anyway, based on the bad experience from the above, I wonder about:
- Difference in using (.*) vs. ([^.]+)
- Difference in using RedirectMatch vs. RewriteRule
Thanks