Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-12-2012, 03:59 PM   PM User | #1
timgolding
Senior Coder

 
timgolding's Avatar
 
Join Date: Aug 2006
Location: Southampton
Posts: 1,460
Thanks: 89
Thanked 110 Times in 109 Posts
timgolding is on a distinguished road
Redirect Permament

I am trying to eliminate domain.com and force the user to use only www.domain.com

i read some articles on the internet about how to achieve this but they didn't want to work for me

i tried this for my virtual host file

Code:
<VirtualHost *:80>
        ServerName www.domain.co.uk:80
        # All other stuffs for domain below......
</VirtualHost>
<VirtualHost *:80>
        ServerName domain.co.uk:80
        RedirectPermanent / "http://www.domain.co.uk"
</VirtualHost>
which works for domain.co.uk. typing in domain.co.uk in to the address bar on my browser successfully redirects me to www.domain.co.uk. The problem is when i put something like domain.co.uk/About instead of directing to www.domain.co.uk/About it directs to www.domain.co.ukabout. Is there anyway to get any page to redirect to www.domain.co.uk/About?
__________________
You can not say you know how to do something, until you can teach it to someone else.
timgolding is offline   Reply With Quote
Old 07-13-2012, 09:02 AM   PM User | #2
timgolding
Senior Coder

 
timgolding's Avatar
 
Join Date: Aug 2006
Location: Southampton
Posts: 1,460
Thanks: 89
Thanked 110 Times in 109 Posts
timgolding is on a distinguished road
My solution was to use RedirectMatch instead

Code:
<VirtualHost *:80>
        ServerName www.domain.co.uk:80
        # All other stuffs for domain below......
</VirtualHost>
<VirtualHost *:80>
        ServerName domain.co.uk:80
        RedirectMatch permanent ^/(.*) http://www.domain.co.uk/$1
</VirtualHost>
__________________
You can not say you know how to do something, until you can teach it to someone else.
timgolding is offline   Reply With Quote
Old 07-15-2012, 09:11 PM   PM User | #3
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
You are missing a trailing slash in your original code
Code:
RedirectPermanent / http://www.example.co.uk/
No quotes are required either.
schleppel is offline   Reply With Quote
Reply

Bookmarks

Tags
domain to www, redirect permament

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:25 PM.


Advertisement
Log in to turn off these ads.