문제

When I visit my "domain.com/?" or "domain.com/?any-other-character-here" it shows my homepage, this caused duplicate results in Google. Web server is Apache.

My code is

ErrorDocument 404 domain.com/error404.html

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain.com

RewriteRule (.*) domain.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} \s/+\?\s

RewriteRule ^ /? [R=301,L]

It redirects non-www to www and I added your code in it. But still see domain.com/?any-random-text doesn't redirect to 404

도움이 되었습니까?

해결책

To fix 404 and problems of domain.com/? you can have this rewrite code:

ErrorDocument 404 http://domain.com/error404.html

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+\?
RewriteRule ^ /? [R=301,L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top