Solved

redirect site root to a subdirectory using htaccess

Posted on 2010-08-21
4
538 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IDE for Python 5 100
Powershell PGP and SFTP 1 42
use .htaccess to re-write URL 3 21
Notepad++ Question 11 21
This article will show, step by step, how to integrate R code into a R Sweave document
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

740 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