1

I need to create a htaccess 301 redirect that redirect all

www.mydomain.dk/40005/ (Where 40005 can be any 5 digit number) to www.mydomain.dk

Anyone know how to do that?

1

2 Answers 2

1

IT is simple :

RewriteEngine On
RewriteRule ^[0-9]{5}/?$ / [QSA,L,R=301]
0
1

In your document root's htaccess file, or in your vhost config:

RedirectMatch 301 ^/[0-9]{5}/?$ /

ALternatively, you can also use mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.dk$ [NC]
RewriteRule ^/?[0-9]{5}/?$ / [L,R=301]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.