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 3 of 3
  1. #1
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts

    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.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    You are missing a trailing slash in your original code
    Code:
    RedirectPermanent / http://www.example.co.uk/
    No quotes are required either.


  •  

    Tags for this Thread

    Posting Permissions

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