Redirecting requests for .html pages in subdirectories to the same page in root with .htaccess
Redirecting requests for .html pages in subdirectories to the same page in root with .htaccess -
Solution :
Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :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.
Edited because other one failed:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/subblog/(.*)$ http://www.example.com/$1 [R=301,L]
Can you try this and give the results?
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
Comments
Post a Comment