Question

I have found lots of .htaccess pointing tuts for subfolder to root (domain TLD) but not a first level foder to a second level subfolder. Scenario: I need to have my .htacces to show the (www.)example.org/folder/ URL, but to use all the resources as it would be (www.)example.org/folder/sub-dir/ So, how do I write the .htaccess in the SiteRoot so that this subfolde "/folde/" point to "/folder/sub-dir/" without any exceptions to resources inside /sub-dir/.

Please help me get out of the mud.

Was it helpful?

Solution

Place this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(sub-dir(?:/.*)?)$ /folder/$1 [L,NC]

RewriteRule ^folder((?!sub-dir)/.*)?$ /folder/sub-dir/$1 [L,NC]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top