1

I have the following rules in my .htaccess file, I want to know how can I rewrite my URLs from www.mydomain.com to mydomain.com, I'm using Kohana 3.2 and haven't found info about it.

RewriteEngine On
RewriteBase /

RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT]

I have tried the following:

    RewriteEngine On
    RewriteBase /

    RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
    RewriteRule ^(.*)$ http://mydomain/$1 [L,R=301,NC]

    RewriteRule .* index.php/$0 [PT]

But it results into "too many redirects"

JohnnyAce
  • 3,569
  • 9
  • 37
  • 59
  • check out this thread: http://stackoverflow.com/a/1270281/1409771 – DNReNTi Aug 13 '15 at 08:43
  • 5
    possible duplicate of [Generic htaccess redirect www to non-www](http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www) – DNReNTi Aug 13 '15 at 08:44
  • You're looking for something like this: `RewriteCond %{HTTP_HOST} ^www\.` `RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]`. – Andrei Aug 13 '15 at 08:47

1 Answers1

0
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%2://%1%{REQUEST_URI} [L,R=301]
anandsa
  • 1
  • 2