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 10-09-2012, 09:19 PM   PM User | #1
strom73
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
strom73 is an unknown quantity at this point
Mod_rewrite + direct www to non-www not working together

Hello,

I have mod_rewrite enabled on my forum. The code looks like this in .htaccess:

Code:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} .*\.(jpeg|jpg|gif|png)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /public/404.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Now, I want to redirect WWW to non-www with this code:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST}  ^www.myforum.eu [nocase]
RewriteRule ^(.*)         http://myforum.eu/$1 [last,redirect=301]
When I add the code to the end of the file, it starts to redirect www.myforum.eu/page1.html to the index.php file because of the "RewriteRule . /index.php. How could I get both www to non-www and mod_rewrite SEO friendly URL's working?
strom73 is offline   Reply With Quote
Old 10-11-2012, 08:14 PM   PM User | #2
stevenmw
Regular Coder

 
stevenmw's Avatar
 
Join Date: Jun 2007
Location: OK
Posts: 446
Thanks: 26
Thanked 30 Times in 30 Posts
stevenmw is an unknown quantity at this point
To redirect www to non www it is

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]
stevenmw 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 12:13 AM.


Advertisement
Log in to turn off these ads.