Question

Hello,

I am trying to make it so that if someone visits http://www.moneythink.org/mtnet, they get redirected to http://moneythink.org/mtnet (removing the "www" at the beginning).

I looked online, and put the following in my .htaccess file:

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

But then when I go to http://www.moneythink.org/mtnet, it just sends me to http://moneythink.org (instead of http://moneythink.org/mtnet).

Any ideas why this is happening?

Pas de solution correcte

Autres conseils

I am using this on my production server, try it once, instead of $1 use complete {REQUEST_URI}

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top