Reputation: 67
I'm trying to add a simple .htaccess 301 redirect. urls like:
s.nl/sc/2.f?...
s.nl/it...
s.nl/?=...
I would like to match any url that starts with "s.nl".
What I've been trying is:
RewriteRule ^s\.nl/.*$ / [L,R=301]
Update: This is the final rule that worked correctly:
RewriteRule /s\.nl.*$ /? [R=301]
Upvotes: 0
Views: 188
Reputation: 26
The regular expression you have is almost correct. In your RewriteRule it looks like you are trying to match the /
after s.nl
, if this is the case then the /
has to be escaped (\/
):
RewriteRule ^s\.nl\/ / [R=301]
The L
flag is most likely not required, unless you have additional rules using RewriteCond
.
If you want anything to be matched after s.nl
then the RewriteRule
is simply:
RewriteRule ^s\.nl / [R=301]
nb. if you want the drop the query string when redirecting you can add ?
to the redirect destination:
RewriteRule ^s\.nl.*$ /? [R=301]
Upvotes: 1