Solved

redirect site root to a subdirectory using htaccess

Posted on 2010-08-21
4
527 Views
Last Modified: 2012-06-21
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
Comment
Question by:teenaw
  • 3
4 Comments
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 33493793
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
 

Author Comment

by:teenaw
ID: 33494097
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
 

Author Comment

by:teenaw
ID: 33494101
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
 

Author Comment

by:teenaw
ID: 33494118
This was the answer, I just don't have access.  

Thanks for your help.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

929 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

15 Experts available now in Live!

Get 1:1 Help Now