• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

redirect site root to a subdirectory using htaccess

Hi,

Launching a new site, I am having trouble getting rid of the "beta" that appears in the url of a new website.  I edited htaccess trying to make the Apache server use a sub-directory as root with partial success.

The  site can be accessed at www.sitename.com or beta.sitename.com which is fine, but either way, all the interior links include /beta/ in the path.  If I remove the /beta/ from the path in the url, it resolves to the old site.

I am trying to make the server ignore /public_html/ and instead treat /public_html/beta/ as root.  What am I doing wrong?  The code used in htaccess follows.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?sitename.com$
RewriteCond %{REQUEST_URI} !^/beta/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /beta/$1
RewriteCond %{HTTP_HOST} ^(www.)?sitename.com$
RewriteRule ^(/)?$ beta/index.php [L]

Open in new window

0
teenaw
Asked:
teenaw
  • 3
1 Solution
 
Brad HoweCommented:
Hi,

Why can't you just change the DocumentRoot to "/home/username/public_html/beta? OR back up and move the beta files into the root.

The issue with your rules are that you are

1. checking the host domain
2. make sure it is not /beta
3. making sure that it is a file or directory

Then redirect request to www.sitename.com/beta/$1 

The next rule simply redirects the root.

So beta will always exist because it is a TRUE directory in your virtual host.


As mentioned above, why not just flip the document root in the httpd.conf?

-Hades666

0
 
teenawAuthor Commented:
Hi Hades,  

Re: change the DocumentRoot to "/home/username/public_html/beta / flip the document root in the httpd.conf

Is EXACTLY what I would lile to do, I am trying to figure out how.  Not that I know the name of the file, I will check to see if I have access.  Thanks for cluing me in!
0
 
teenawAuthor Commented:
That was full of typos...  

...would like to do, I am trying to figure out how.  Now that I know the name of the file....
0
 
teenawAuthor Commented:
This was the answer, I just don't have access.  

Thanks for your help.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now