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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mod rewrite not working

    I have a site with a blog in a separate folder, so there is mysite.com and mysite.com/blog.

    I'm trying to have all pages go to www. For my main site it works fine. But for my blog it does not. So:

    mysite.com redirects properly to www.mysite.com
    mysite.com/blog/ stays at mysite.com/blog/ instead of www.mysite.com/blog/

    Here is the htaccess code for my main site www.mysite.com:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?virtualpath=$1 [L]
    </IfModule>

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite\.com
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]


    Here is the htaccess in blog directory www.mysite.com/blog/:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?virtualpath=$1 [L]
    </IfModule>

    Any suggestions?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Remove the .htaccess from ./blog. I don't see a reason to leave it there at all as its missing any rule indicating that a redirect to www. should exist, and the only rule it has is already within the root .htaccess.
    Why is the second rule in the root .htaccess outside of the check for mod_rewrite.c? Put everything within the check for rewrite, except the second rewrite engine directive, you can just remove that.

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fou-Lu, that did it, thanks for the help!

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, that led all my individual blog pages to a page not found message, so I uploaded the htaccess back to the /blog and now it works. Thanks again.


  •  

    Posting Permissions

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