-
301 Redirect Question
Can anyone explain how to redirect all files in a certain directory to a single, alternative page, using 301 Redirect?
I was to delete a section of a site of mine and make all visitors trying to access any of those pages, currently within a certain directory, redirect to a different landing page.
-
You can do it through your .htaccess file.
First of all, make sure your Rewrite engine is set to on:
Then, after this line, you can do:
Code:
RewriteRule ^sectiontobemoved/ /landig-page.html [R=301,L]
-
Thanks!! :)
Didn't quite work for me but sent me in the right direction. The code that actually worked for me was:
ReWriteRule ^sectiontobemoved/.*$ /landingpage.html [R=301,L]
:)
-
My fault, sorry. Forgot the ".*$" 'wildcard'.
In some cases (as yours) you need to specify "also files contained in", so ".*$".
I'm glad it works ;)
-
Thanks for the discussion guys - that saved me a couple of hours research later on today
Much appreciated
:joy:
-
If you are running wordpress, there are plugins for 301 redirects that are fairly easy to use as well.
Regards
-
Using a plugin to do redirects that can be much faster in htaccess adds more overhead than necessary.
Rick
Universal4