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
    Regular Coder
    Join Date
    Aug 2006
    Location
    Richmond, CA
    Posts
    152
    Thanks
    3
    Thanked 5 Times in 5 Posts

    Redirecting folder to sub-domain

    Greetings,

    I am working on a site where we are using a subdomain (dir.domain.com). Previously, the users were accessing the folder directly (www.domain.com/dir), but we want to force them to use the subdomain.

    I've tried to do it using the mod_rewrite, but having trouble. This is what I have:


    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com
    RewriteRule ^/dir(/.*)?$ http://dir.domain.com$1 [R=301,L]
    It doesn't seem to be working properly, though. When I type in http://www.domain.com/dir/whatever.php, there's no redirect.

    Any pointers appreciated. Thanks.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Try this in your document root .htaccess:
    Code:
    RewriteEngine on
    RewriteRule ^dir(.*)?$ http://dir.domain.com$1 [R=301,L]

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Location
    Richmond, CA
    Posts
    152
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Inigoesdr View Post
    Try this in your document root .htaccess:
    Code:
    RewriteEngine on
    RewriteRule ^dir(.*)?$ http://dir.domain.com$1 [R=301,L]
    Thanks for the effort, but no change.


  •  

    Posting Permissions

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