stefmikhail
stefmikhail

Reputation: 7125

Difference between mod_rewrite redirects?

I have the following two mod_rewrite redirects. They both appear to do the same thing, but I'm not sure why one is two lines longer than the other. (I've been using the longer one btw):

1:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^$ shows [L]

2:

RewriteEngine On
RewriteRule ^$ /shows [L]

Upvotes: 0

Views: 244

Answers (1)

Clive
Clive

Reputation: 36957

The extra two lines simply forward requests for any page at example.com to the same page at www.example.com, performing a 301 permanent redirect (hence the R=301...).

It's good practice not to have duplicate content on two domains (for SEO purposes) so most people these days forward example.com to www.example.com; the other way around is also perfectly valid and quite widely used (ie. redirecting www.example.com to example.com).

Upvotes: 1

Related Questions