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 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Force www on a subdirectory

    Hi i have a site with subdirectories

    The main one is mysite.com and i have the "force www" code on the main domain so it changes to http://www.mysite.com

    I have a sub directory, mysite.com/page1 and i would like a htaccess code to "force www" on my sub directory and everything inside it.

    For example:

    mysite.com/page1
    Would be changed to http://www.mysite.com/page1

    And everything else in the "page1" subdirectory gets forced with "www"

    Example: mysite.com/page1/forum.php
    Would change to: http://www.mysite.com/page1/forum.php


    Thanks in advance

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/page1/$1 [R=301,L]
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Where do i Insert my domain in that code?

    Amd
    I want the "force www" only to work when someone types: mysite.com/page1

    If they type www.mysite.com/page1 Then it shouldnt redirect

  • #4
    New Coder
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    help????

  • #5
    New Coder
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Anyone help??

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Did you try abduraooft's code? You don't have to enter your domain because he used %{HTTP_HOST}, which is the requested domain.


  •  

    Posting Permissions

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