Reputation: 1629
I need to update my htaccess file because of a change in SEO. The update is from this style domain.org
to www.domain.org
. So there needs to be a 301 update to the file.
How would I add 301 redirects? Also, do I need to change the index.html
sections to www.index.html
along with the 301 addition?
This is what my htaccess looks like now.
ErrorDocument 404 /404.html
RewriteEngine On
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.html?x=$1&y=$2&z=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/?$ index.html?x=$1&y=$2 [L]
RewriteRule ^([^/]+)/?$ index.html?x=$1 [L]
I've fouled up htaccess in the past, so I appreciate the help.
Upvotes: 1
Views: 39
Reputation: 785866
You can use:
ErrorDocument 404 /404.html
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.org$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.html?x=$1&y=$2&z=$3 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.html?x=$1&y=$2 [L,QSA]
Upvotes: 1