Home › Forums › Other › How to remove subdirectories using mod_rewrite in .htaccess › Reply To: How to remove subdirectories using mod_rewrite in .htaccess
I change my directory structure to:
Root (example.com)/
index.html
contact.html
privacy.html
disclaimer.html
routine/
play-games.html
do-exercise.html
eat-food.html
I decided not to use RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
anymore so how should I rewrite my code to perform these:
Address bar shows: example.com/play-games
or example.com/play-games/
User sees: example.com/routine/play-games.html
Address bar shows: example.com/eat-food
or example.com/eat-food/
User sees: example.com/routine/eat-food.html
etc…
As I’m still confused with when and how to use REQUEST_FILENAME and REQUEST_URI, I don’t know what sort of RewriteCond I should put in.
RewriteCond ?????
RewriteRule ^(.*)/?$ /routine/$1.htm [L]
And I would like to perform these as well:
Address bar shows: example.com/contact
or example.com/contact/
User sees: example.com/contact.html
Address bar shows: example.com/privacy
or example.com/privacy/
User sees: example.com/privacy.html
I know I have to do something extra but I just don’t know what conditions I should include. Please advise.
Appreciate your help in this. Thanks.