Mobile app version of vmapp.org
Login or Join
Angie530

: 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

@Angie530

Posted in: #Htaccess #Redirects

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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

2 Comments

Sorted by latest first Latest Oldest Best

 

@Barnes591

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

10% popularity Vote Up Vote Down


 

@Rambettina238

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?

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme