Paulcraey
Paulcraey

Reputation: 391

How can I redirect url's with htaccess?

I have a site with some url's :

www.example.com/nl-foo1.php
www.example.com/nl-foo2.php
www.example.com/nl-foo3.php

I changed the filenames to :

www.example.com/foo1.php
www.example.com/foo2.php
www.example.com/foo3.php

I want a user to user that gives in www.example.com/nl-foo1.php to be redirected to www.example.com/foo1.php

I guess that can be done with htaccess? But how?

Upvotes: 1

Views: 25

Answers (1)

anubhava
anubhava

Reputation: 784898

You can use this redirect rule as topmost rule in your site root .htaccess:

RewriteEngine On

RewriteRule ^nl-(.+)$ /$1 [L,NC,NE,R=301]

Upvotes: 1

Related Questions