0

I need to add some rewrite rules to a website.

Here's the idea =>

Rewrite all non-subdomain traffic from

(http or https)://(www. or no www.)example.com/whatever
(http or https)://www.example.com/whatever

(so basically, always force www.)

Also rewrite only this 1 sumbdomain =>

(http or https)://(www. or no www.)store.example.com/whatever
(http or https)://www.example.com/whatever

Keep all other subdomains intact.

So far I have this =>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{HTTP_HOST} ^store.example.com$
RewriteRule ^(.*)$ http%{ENV:askapache}://www.example.com/$1 [R=301,L]

But it's not working as expected...

Any help would be appriciated.

Thanks!!

4

1 回答 1

1

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(?:store\.)?example\.com$ [NC]
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.example.com%{REQUEST_URI} [R=301,L]
于 2013-03-30T16:04:52.517 回答