I’m trying to redirect all requests for a subdirectory and any files in it to the root directory, using htaccess. Currently I have redirect 301 /directory/ / But this redirects to the root with the file name requested appended to it.. ie http://www.domain.com/directory/this.html redirects to http://www.domain.com/this.html I don’t want it to request the file at all. Is there a way to do this?
Thank you
Karl
You will probably have to use mod_rewrite. Assuming you place the .htaccess in the root directory, something like this should work.
NB. I put 302, as it’s always sensible to use for testing, 301 can make it a pain checking changes with your browser. Once it’s working feel free to change to 302.