views:

222

answers:

4

I am trying to redirect my whole site to non-www

here is the htaccess code I am using

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

# no www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]

any ideas

A: 
Urda
A: 

Hi I think you need to adjust your script as follows for the rewriting to work:

Options +FollowSymlinks
RewriteEngine on

I believe that the follow symlinks absolutely has to be included for url rewriting to work properly.

More advice on mod_rewrite here:

http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html

Rob

Robin Layfield
A: 

I think your rules need to between the module tags.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# no www
RewriteCond %{HTTP_HOST} ^www\.akorra\.com$ [NC]
RewriteRule ^.*$ http://akorra.com%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

</IfModule>
Nick Berardi
A: 
RewriteEngine On
RewriteBase /

# no www
RewriteCond %{HTTP_HOST} ^([^.]+)\.akorra\.com$ [NC]
RewriteRule ^(.*)$ http://akorra.com/$1 [R=301,L]

# WordPres
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

This should work

ahmet2106