Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

759 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

18 Experts available now in Live!

Get 1:1 Help Now