Solved

redirect site root to a subdirectory using htaccess

Posted on 2010-08-21
4
525 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This was the answer, I just don't have access.  

Thanks for your help.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
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.
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 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

6 Experts available now in Live!

Get 1:1 Help Now