Solved

htaccess - how to redirect to a new folder WITHOUT having that folder appear in the http path?

Posted on 2013-05-10
3
331 Views
Last Modified: 2013-05-10
Our site currently resides in the root directory established by the web host.

We've set up a new site in a subfolder of our current site called '/blog/'.

We wish to make the new site (the one in the subfolder called /blog/) the live active site so that when users enter in our domain name, it automatically takes them to our new site in the /blog/ subfolder.

BUT - we don't want the name of the subfolder to appear in the user's browser's address bar. We still want the user's address bar to simply read our domain name, and NOT contain the word '/blog/' in the path.

Is this possible with htaccess? Or do we need to ask the web host to change the default folder?

Every attempt we've made (including the one referenced on the WordPress site: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory) results in the user being directed to the '/blog/' folder but it shows '/blog/' in the path.

thanks experts!
0
Comment
Question by:rascal
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Greg Alexander earned 500 total points
ID: 39156399
Something like this should work in the root of your site in a .htaccess file

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/$1
RewriteCond %{HTTP_HOST} ^(www.)?yoursite.com$
RewriteRule ^(/)?$ blog/index.php [L]

Open in new window

0
 
LVL 1

Author Comment

by:rascal
ID: 39156562
That worked for the homepage (index.php) of our wordpress blog, but all the other include files that reference the domain still try to find the files in the old website path. (such as .js files, css files, etc)
0
 
LVL 1

Author Closing Comment

by:rascal
ID: 39156961
Thanks, please disregard my follow-up message, your solution worked.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question