huzibizi
huzibizi

Reputation: 109

How to redirect a specific page using htaccess

I've looked all over for the htaccess code to redirect a single page and haven't had any luck with many solutions.

Basically I need to redirect this:

/example/my-stuff/

to:

/example/home/

but I don't want any other pages except for /my-stuff/ to be redirected. Eg. these pages should not be redirected and kept the same.

/example/my-stuff/a-page
/example/my-stuff/anything

Upvotes: 3

Views: 13390

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

In the htaccess file in your document root, you can add either this:

RedirectMatch 301 ^/example/my-stuff/$ /example/home/

Or you can use mod_rewrite instead:

RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]

Upvotes: 9

Related Questions