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.
精彩评论