Solved

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

Posted on 2013-05-10
3
327 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now