开发者

301 redirect without index

开发者 https://www.devze.com 2023-03-14 12:59 出处:网络
I saw many 301 questions but I haven\'t found a solution for mine so I\'ll just post it here. The standard 301 looks something like this:

I saw many 301 questions but I haven't found a solution for mine so I'll just post it here.

The standard 301 looks something like this:

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

Well, when I surf to my website I end up on www.domain.tld/index.php/restofquery. I want to get to www.domain.tld/ when I surf to domain.tld and I also want no index.php in any other query. So domain.tld/articlebla sho开发者_StackOverflow社区uld be www.domain.tld/articlebla.

Any way to accomplish this?

Best regards.


To simply add on the www you would do:

RewriteCond %{http_host} ^301redirect\.de$ [NC]
RewriteRule ^/?$ http://www.301redirect.de/ [R=301,NC]

To also add on the other urls parts and www, you would do:

RewriteCond %{http_host} ^301redirect\.de$ [NC]
RewriteRule ^(.*?)/?$ http://www.301redirect.de/$1/ [R=301,NC]

If you mean you don't want the original query string on the redirect url then this will work:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.301redirect\.de$
RewriteRule ^(.*)$ http://www.301redirect.de/$1/? [L,R=301]

Adding a ? to the end of the RewriteRule means that the query string won't get added.

0

精彩评论

暂无评论...
验证码 换一张
取 消