Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2008
    Location
    Ohio, USA
    Posts
    29
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question 301 redirect, Apache mod rewrite

    Hi all,

    Dennis here. I hope I am posting this question in the correct section of the forums. If not please let me know which coding or other section this question would best fit into.

    I am new to this forum and looking for some expert advice on redirecting a domain name that I've purchased on Godaddy and pointing it to a folder that will house this domains website on my current webserver where my business website resides. I have made the necessary DNS changes to the domain name from Godaddy so that it points to my business web hosting server. Now I just need it to point to it's homefolder.

    I am with verio.com's webhosting service (their basic UNIX plan, and I've just moved to that plan from an older verio plan (the new plan costs half as much but seems to offer more, go figure ). My IP address and server have changed and I have made all the DNS modifications necessary. Everything seems to be in order now except one thing. When I was on the old plan I was able to 'virtual host' a website for a club that I am in, domain name laughingclubneo.com (The Laughing Club of Northeast Ohio). Domain was purchased through Godaddy.com and I changed the DNS numbers at Godaddy to point this domain to my new server with Verio. I was able to virtual host the laughing club site on my old verio server via a redirect by adding a .htaccess file to the root directory (scroll down to 'redirect a machine name'). I am operating on a Mac Pro using OS 10.5.5 The instructions for creating the .htaccess file said to start with just the ".".
    When I tried to save a file on my hard drive using text edit in ASCII or plain text mode I got a popup warning that any files saved using just a "." at the beginning were strictly for the system and would become invisible. Well this is what happened. So I named the .htaccess file vh.htaccess (vh for virtual hosting). Here is the code that I used in the file which worked on the previous plan/server to redirect the laughingclubneo.com domain to a folder in my root directory called laughingclubneo.com :

    <Files vh.htaccess>
    order allow,deny
    deny from all
    </Files>
    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} laughingclubneo.com$
    RewriteCond %{REQUEST_URI} !laughingclubneo.com/
    RewriteRule ^(.*)$ laughingclubneo.com/$1
    <Files vh.htaccess>
    order allow,deny
    deny from all
    </Files>

    I tried adding this file to the root directory on my new Verio server and it isn't working. I was told by a Verio tech support person that they could not help me in writing a redirect code (even though a week before another Verio tech support guy had done just that ) but said that I needed to Google and research something called a 301 redirect.

    I googled '301 redirect' and accessed this tutorial which I couldn't really figure out, even though it seemed simpler than the other code, lol.

    I am here to ask anyone if they can help me with this redirect code or process so that I can put a cap on this server/plan move and have everything working again.
    I know that virtual hosting is possible and done all the time and I am confident that I will get some great suggestions here on this forum.

    Thanks in advance for any input.

    Best,

    Dennis

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I don't have a solution for you (its been so long since I've actually dealt with domains).
    Just letting you know that I'm moving this to 'other serverside issues' forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    When I tried to save a file on my hard drive using text edit in ASCII or plain text mode I got a popup warning that any files saved using just a "." at the beginning were strictly for the system and would become invisible. Well this is what happened. So I named the .htaccess file vh.htaccess (vh for virtual hosting).
    Can't you rename it to .htaccess once you have uploaded it to the server? Unless it is configured to look for vh.htaccess, Apache will be looking for a .htaccess file and you mod_rewrite will not get processed.

    Then your .htaccess file can be
    Code:
    Options +FollowSymLinks
    
    RewriteEngine On
    
    # Fix missing trailing slashes.
    RewriteCond %{HTTP_HOST} ^(www\.)?laughingclubneo\.com$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/laughingclubneo.com%{REQUEST_URI}/ -d
    RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
    
    # Rewrite domain.
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{HTTP_HOST} ^(www\.)?laughingclubneo\.com$ [NC]
    RewriteRule ^(.*)$ /laughingclubneo/$1 [QSA,L]

  • #4
    New Coder
    Join Date
    Dec 2008
    Location
    Ohio, USA
    Posts
    29
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Smile thanks

    Thanks Schleppel,

    I'm really not familiar with coding at all, except a little html and css.
    This is kind of beyond me and I have only attempted this at the suggestion of a tech support guy at my web hosting company, verio.com.
    He said that hosting a DNS only domain registered with a different company (Godaddy.com) could be accomplished with a .htaccess file code modification.
    I tried it on my previous verio plan and the file 'vh.htaccess' worked.
    I only put the prefix on so that I could see the file. Uploading a .htaccess file to my root directory with a prefix, then renaming it by deleting the prefix makes it immediately disappear. I'm not sure where it goes or how I can view the contents of the file after this has happened. On one of my recent tries at redirecting a domain through .htaccess code modification, it caused an internal server error on my hosting server and my main site dennisroliff.com would not load. I found this out by asking a verio tech guy what was going on. So I want to be careful what code I put into this .htaccess file so as not to cause a server error. I'm not sure if the .htaccess file is already in my server code (UNIX) with default code which shouldn't be messed with or if it is an auxiliary file that one can add to accomplish certain tasks. One thing about my previous verio hosting plan (and perhaps the reason that the mod rewrite worked on that plan) is that I was able to add a DNS only domain to my domain list in the Control Panel and edit the zone list (something I'm not able to do on my current plan). I'm not sure if it is key that the domain info actually resides on your hosting server or if one can just change the DNS settings at a separate hosting site (Godaddy.com, the domain registrar) and point it to the correct nameservers at verio and get the redirect to work.
    I will give your code a try and if for some reason I get an internal server error, as I have recently, what I do to correct it is to upload a .htaccess file with no code in it. That seemed to fix the problem last time.

    Any further input that you can give will be greatly appreciated.

    Thanks.

    Dennis

  • #5
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    Uploading a .htaccess file to my root directory with a prefix, then renaming it by deleting the prefix makes it immediately disappear. I'm not sure where it goes or how I can view the contents of the file after this has happened.
    On Unix-like operating systems files starting with a dot are hidden (more info). If you are using an FTP client there is almost certainly an option to show any hidden files. You can also show hidden files on a Mac.

    One thing about my previous verio hosting plan (and perhaps the reason that the mod rewrite worked on that plan) is that I was able to add a DNS only domain to my domain list in the Control Panel and edit the zone list (something I'm not able to do on my current plan). I'm not sure if it is key that the domain info actually resides on your hosting server or if one can just change the DNS settings at a separate hosting site (Godaddy.com, the domain registrar) and point it to the correct nameservers at verio and get the redirect to work.
    What happens when you visit the domain? If it times out the DNS is wrong. If it goes to your hosting's IP address the DNS is correct. Unless you have done something special (transferring your domain) you should be able to control your DNS from the Godaddy control panel.

  • Users who have thanked schleppel for this post:

    droliff (12-31-2008)

  • #6
    New Coder
    Join Date
    Dec 2008
    Location
    Ohio, USA
    Posts
    29
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Thumbs up Success!

    Schleppel,

    Thank you, Thank you, Thank you for helping me out with this .htaccess mod_rewrite. Finally after going round and round with various tech and domain people at Verio I whittled down the solution and your code was absolutely key. Believe me, I am no coder and had to figure this whole process out by asking experts like yourself and just stumbling through the process like a bull in a china shop.
    Here is what my process was:
    I had two hosting accounts open on Verio (which was part of the problem)
    I recently moved to a more cost effective and actually better plan than the one I had been on for about 8 years. I closed the previous accounts hosting service which was on group 19 nameservers.net and thought the slate was wiped clean but apparently the domain registration remained open on that account so the DNS config for my subdomain (laughingclubneo.com) was still on those servers. I told them to move both the primary domain registration (dennisroliff.com) and sub or DNS only domain (registered at Godaddy.com) to the new hosting plan. I made sure my DNS config in the control panel at GoDaddy pointed to the new Verio servers (group 14) and then tried some variations on a mod_rewrite for a .htaccess file to upload to my verio domain root directory.
    I believe I may have given you the initial rewrite which was suggested by one of the Verio techs which I got to work somehow on the previous plan:

    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>
    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} laughingclubneo.com$
    RewriteCond %{REQUEST_URI } !laughingclubneo.com/
    RewriteRule ^(.*)$ laughingclubneo.com/$1
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>

    I was able to FTP .htaccess files to my server by putting a prefix on them i.e. new.htacces and then deleting the prefix when it was in my root directory which immediately made the file invisible. I tried this code after getting the domain reg/old acct. mess straightened out and it gave an internal server error when I tried to log on to my main site (dennisroliff.com)
    I then, just for the heck of it, tried logging into my subdomain (laughingclubneo.com) without any .htaccess file on the server. and I was getting a 'the requested URL/laughingclubneo.com/www/htdocs/ was not found on this server. I knew I was getting closer because at least now it was hunting on the correct server.
    The coup de grace came when I retried the code you initially suggested:

    Options +FollowSymLinks

    RewriteEngine On

    # Fix missing trailing slashes.
    RewriteCond %{HTTP_HOST} ^(www\.)?laughingclubneo\.com$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/laughingclubneo.com%{REQUEST_URI}/ -d
    RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

    # Rewrite domain.
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{HTTP_HOST} ^(www\.)?laughingclubneo\.com$ [NC]
    RewriteRule ^(.*)$ /laughingclubneo/$1 [QSA,L]

    This gave me a 'the requested URL/laughingclubneo/ was not found on this server.
    I took a look at your code again and, since the directory for the laughingclubneo.com site was named laughingclubneo.com I just changed
    the last line of your code to read:
    RewriteRule ^(.*)$ /laughingclubneo.com/$1 [QSA,L]

    And Bingo, the temporary page I designed came right up when I typed in either laughingclubneo.com or www.laughingclubneo.com into my Firefox browser.
    I could have cried, but laughed out loud instead .

    Even though I don't know what all that code means, I now have a good idea on how to redirect other subdomains on any future projects.

    Thanks so much again. Bravo!

    Best,

    Dennis


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •