MathiasH
MathiasH

Reputation: 115

htaccess 301 redirect pattern needed

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?

Upvotes: 1

Views: 269

Answers (2)

Oussama Jilal
Oussama Jilal

Reputation: 7739

IT is simple :

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

Upvotes: 1

Jon Lin
Jon Lin

Reputation: 143886

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]

Upvotes: 1

Related Questions