Question : 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.
1:
2:
3:
4:
5:
6:
7:
8:
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]

Answer : redirect site root to a subdirectory using htaccess

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

Random Solutions  
 
programming4us programming4us