How do I 301 redirect from the root folder to a sub folder while keeping the rest of the URL string intact

How do I 301 redirect from the root folder to a sub folder while keeping the rest of the URL string intact - .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 php, htaccess, 301-redirect, , .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 :


When I first launched my site, it I had MediaWiki in the root and a wordpress blog in a subfolder, /blog/.



After a while spammers took over the MediaWiki site and I had to remove it. The problem is I lost a lot of good content and inbound links from 3rd party sites.



My goal is to redirect the root folder to /blog/ while keeping the rest of the URL string intact. I have a Wordpress plug-in going that will automatically track the 404 errors. As these come in I'll be able to pull the old content from archive.org and give it a new home on a wordpress page.


Solution :

Try using mod_alias in Apache.



For example:



# When someone visits "/" (root) actually take them to "/blog".
Alias / /blog

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.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect