Could someone please tell me how to use .htaccess to redirect the following: mydomain.com/subfolder to mydomain.com I am sure this is a stupid question but I have been looking for hours and haven't found an answer yet. Thank you for your help!
Make an .htaccess file with this lines, and put it into that specific folder: RewriteEngine On RewriteRule ^.*$ / [R=301,L] Code (markup): That rule should redirect every attempt to open any file or subfolder or subfolder/file to your root url. Make sure you are uploading your .htaccess file with those rewrite rules to that specific folder, and not in your root html folder of your site.
Hi pr0t0n, I have a similar problem: I need to do the redirect in this way: mydomain.com/subfolder/subfolder1/subfolder2/ to mydomain.com Following your instructions works only for the first subdirectory (mydomain.com/subfolder/ to mydomain.com) Do you have any suggestions to be able to realize what is necessary? Regards, Max
You can also put a single .htaccess at the root of your website: RewriteEngine On RewriteRule ^subfolder/(.*)$ / [R=301,L] Code (markup):
Another small problem: there are some static pages that are called as the folder. By setting the rule they are wrongly redirected too For example, mydomain.com/subfolder.html is redirect to home page because in the .htaccess file there is the rule RewriteRule ^subfolder/(.*)$ / [R=301,L] How can I prevent these static pages with the same folder name from not being redirected? Regards, Max