1
votes

On https://stackoverflow.com/a/1270281/891052 there's a solution for "Generic htaccess redirect www to non-www". It makes the site 301 Redirect from www to non-www without the need of specifying the domain name.

It looks like this:

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

What I have tried to accomplish is to add a rule to it where /home redirects to the root.

In other words that http://example.com/home and http://www.example.com/home go to http://example.com regardless of the domain name.

But I can't figure out how.

1

1 Answers

1
votes

You can use:

RewriteEngine On

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

RewriteRule ^home/?$ / [NC,L]