Append domain to server name?

Discuss practical ways rearrange URLs using mod_rewrite.

Append domain to server name?

Postby vonnie » Mon Dec 22, 2008 8:04 am

I see many references for forcing www, but I need to force the domain on an Intranet site. Users currently enter http://server ; I need a rewrite that turns that into http://server.domain.com. I have a rewrite that does this, but I don't have it right because it's looping. Any help is appreciated!

--Vonnie
vonnie
 
Posts: 2
Joined: Fri Dec 19, 2008 8:16 am

Postby richardk » Mon Dec 22, 2008 4:08 pm

What is your attempt?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}.example.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby vonnie » Tue Dec 23, 2008 12:17 pm

Hmmmm....that resulted in an internal server error--no error code though. Here is what I have in the httpd.conf for this rewrite, if it helps:

Code: Select all

<Directory "e:/website/">
    Options All   
    AllowOverride All
</Directory> 


Apache 1.3.22 is what I'm running.

Thanks for your assistance!
vonnie
 
Posts: 2
Joined: Fri Dec 19, 2008 8:16 am

Postby richardk » Wed Dec 24, 2008 8:58 am

Apache only has one document root with all domains treated the same? No <VirtualHost>s?

Does the browser address bar change at all?

Do you have mod_rewrite enabled? Try this mod_rewrite test and enable mod_rewrite if it isn't.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 31 guests

cron