문제

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.

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top