Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 11:38:29 AM

Pages: [1]   Go Down
  Print  
Author Topic: Redirection problem - mod_rewrite  (Read 1191 times)
masonbarge
Spacescooter Operator
*****
Offline Offline

Posts: 40



« on: January 12, 2008, 10:01:03 AM »

Main Problem
This is for a domain "collierhills.net".  I tried to set a general redirect from "www.collierhills.net" to "collierhills.net".  Here is the code I put into the root .htaccess file:
Code:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.collierhills.net [nc]
rewriterule ^(.*)$ http://collierhills.net/$1 [r=301,nc]
This redirects to "collierhills.net/public_html/" and throws a 404 error.  I've tried several things without success.

Herlp!

Smaller Problem
I tried putting the code above (or some variation) in both the root .htaccess and the /public_html/.htaccess files.  Both gave me the problem above.  Now, however, when I take out the Rewrite code, I get the same problem!  It still redirects, only to the /public_html/ file.  In other words, I can't just change it back -- "www.collierhills.net" doesn't work at all.

Logged

"If this is coffee, please bring me some tea. If this is tea, please bring me some coffee."

                  ~ Abraham Lincoln
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5220



« Reply #1 on: January 14, 2008, 02:42:03 PM »

Is collierhills.net a primary or an add-on domain? If it's the primary domain, it ought to work. If it's an add-on, you're probably seeing the URL come in as collierhills.primarydomain.com or possibly primarydomain.com/collierhills/. Are you getting an error message that it's going to collierhills.net/public_html/? If so, where did that "public_html/" come from? Was it in the original URL that you gave? Just what is this root .htaccess you are referring to, and why not public_html/.htaccess? If this is an add-on domain, wouldn't you have public_html/collierhills/.htaccess? Please list your domains and your directory structure (you can substitute fake names -- just be consistent).
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
masonbarge
Spacescooter Operator
*****
Offline Offline

Posts: 40



« Reply #2 on: January 23, 2008, 09:45:05 AM »

Is collierhills.net a primary or an add-on domain? If it's the primary domain, it ought to work. If it's an add-on, you're probably seeing the URL come in as collierhills.primarydomain.com or possibly primarydomain.com/collierhills/. Are you getting an error message that it's going to collierhills.net/public_html/? If so, where did that "public_html/" come from? Was it in the original URL that you gave? Just what is this root .htaccess you are referring to, and why not public_html/.htaccess? If this is an add-on domain, wouldn't you have public_html/collierhills/.htaccess? Please list your domains and your directory structure (you can substitute fake names -- just be consistent).

I very much appreciate your trying to help, but most of the answers to your questions are in my post.  This is a primary domain "collierhills.net".  And I agree, it ought to work.  Confused

The "root .htaccess" is simplay an .htaccess file in the root directory.  I tried putting the redirect in the .htaccess file for both the root directory and the public_html subdirectory.  The idea is that it will redirect the browser to the url "collierhills.net" which will automatically load the following url: "collierhils/index.php"; that is, to the url determined by the server path "root/public_html/index.php".  Instead, it redirects to the actual url "collierhills/public_html/..." 

I hope that's clear.
User types "collierhills.net" -- user gets the url "collierhills.net/index.php", which is determined by the server path "/root/public_html/index.php".  Right?
But when the user types "www.collierhills.net -- user gets the url "collierhills.net/public_html/..." which is nonexistent.
I don't know what else to say.  I type "www.collierhills.net" in my browser and I get a 404 error saying "collierhills.net/public_html" is not available.  For some reason it is reading the public_html directory as the url instead of the source.

This may be an Apache configuration bug -- I'm going to send a ticket.
Logged

"If this is coffee, please bring me some tea. If this is tea, please bring me some coffee."

                  ~ Abraham Lincoln
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5220



« Reply #3 on: January 23, 2008, 10:33:50 AM »

Your primary domain's "root directory" (HTML's "/") is /home/ACCOUNT_NAME/public_html/. Is that what you're referring to, or to an add-on or subdomain subdirectory /home/ACCOUNT_NAME/public_html/subdir/? That would be the "root" to the subdomain or add-on domain. .htaccess files go in the root of a domain/subdomain (or a lower level subdirectory). You should not have added any directories yourself named "public_html". Did you do that? That's the only way I can think of your getting to "collierhills.net/public_html". Please list your domains, add-on domains, subdomains, and their directory structure, as well as the exact location of the .htaccess files and their contents. You can "obscure" real names if you want to.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
masonbarge
Spacescooter Operator
*****
Offline Offline

Posts: 40



« Reply #4 on: January 24, 2008, 05:56:23 AM »

Level I - Root Directory (collierhills.net)
   .cpanel      755
   .cpanel-datastore      700
   .fantasticodata      755
   .gnupg      700
   .htpasswds      755
   .trash      700
   access-logs      750
   etc      755
   mail      770
   public_ftp      750
   public_html      750
   tmp      755
   www      750
   .bash_logout   0 k   0644
   .bash_profile   0 k   0644
   .bashrc   0 k   0644
   .contactemail   0 k   0600
   .ftpquota   0 k   0600
   .lastlogin   0 k   0600
   mysql_articles_edit.php   0 k   0644
   mysql_articles_login.php   0 k   0644
   mysql_articles_user.php   0 k   0644
   mysql_roster.php

/root/public_html/:
   cgi-bin      755
   chforum      755
   greystone      755
   guestbook      755
   images      755
   includes      755
   mixble      755
   px800      755
   snippetmaster      755
   test      755
   ---
   .htaccess   0 k   0644
   Thumbs.db   86 k   0644
   about.php   4 k   0644
   crumbs.inc.php   0 k   0644
   error_log   2 k   0644
   gallery.php   3 k   0644
   index.php   5 k   0644
   newsletter.php   7 k   0644
   path.php   9 k   0644
   php.ini   0 k   0644
   simple_template.php   0 k   0644
   style.css   5 k   0644
   template.html   1 k   0644
   template2.html

I haven't done anything fancy. There is no subdomain, parked domain, or add-on domain in the account.  I have removed .htaccess from the root directory and placed it in the public_html subdirectory.
Logged

"If this is coffee, please bring me some tea. If this is tea, please bring me some coffee."

                  ~ Abraham Lincoln
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5220



« Reply #5 on: January 24, 2008, 09:17:31 AM »

It works for me. Force a reload of the page by either clearing your browser cache or doing a Ctrl-F5... perhaps you're still looking at an old, cached copy? As I said, it worked for me (the address bar showed collierhills.net and the page came up). If it still doesn't work for you...

Is this a shared (Basic or Business plan) or a dedicated server? I'm confused by what you're calling "/root" -- if it's shared, it should be /home/CPANEL_ACCOUNT_NAME/. /home/ACCOUNT/public_html/.htaccess contains what... the code in your original posting?

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.collierhills\.net [NC]
RewriteRule ^(.*)$ http://collierhills.net/$1 [R=301,L]


I don't know if the capitalization will make any difference, but it's worth a try.
« Last Edit: January 24, 2008, 09:19:20 AM by MrPhil » Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1]   Go Up
  Print  
 
Jump to: