: Redirecting requests for .html pages in subdirectories to the same page in root with .htaccess I am porting a site from an old version of a CMS to a newer version which has different page
I am porting a site from an old version of a CMS to a newer version which has different page addressing techniques. I'm unfortunately not very good with htaccess at all.
URL/blog/sublblog/article.html is now simply URL/article.html
Unfortunately, this will destroy any linking programs they have going, and break all the old links. I need a way to use .htaccess say:
if request = /(any subdirectory)/(string).html
then redirect to /(string).html
If that makes any sense.
More posts by @Angie530
2 Comments
Sorted by latest first Latest Oldest Best
You need to do a 301 redirect.
In your .htaccess file, add a line like this:
redirect 301 URL/blog/sublblog/article.html URL/article.html
You will have to do this for each url that you need to redirect, so you could end up adding a ton of entries.
M
Edited because other one failed:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/subblog/(.*)$ www.example.com/ [R=301,L]
Can you try this and give the results?
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.