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 02-03-2012, 12:42 AM   PM User | #1
ubonline
New to the CF scene

 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ubonline is an unknown quantity at this point
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?
ubonline is offline   Reply With Quote
Old 02-03-2012, 07:37 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 02-03-2012, 08:22 PM   PM User | #3
ubonline
New to the CF scene

 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ubonline is an unknown quantity at this point
Fou-Lu, that did it, thanks for the help!
ubonline is offline   Reply With Quote
Old 02-03-2012, 08:47 PM   PM User | #4
ubonline
New to the CF scene

 
Join Date: Dec 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
ubonline is an unknown quantity at this point
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.
ubonline is offline   Reply With Quote
Reply

Bookmarks

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 01:48 AM.


Advertisement
Log in to turn off these ads.