The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other How to remove subdirectories using mod_rewrite in .htaccess Reply To: How to remove subdirectories using mod_rewrite in .htaccess


Yup, I tried your example and that works for a single file.

Maybe I am misunderstanding what you are saying. Take these URLs, for example:

You do not need to create new rules for each of these URLs. The single rule:

RewriteRule ^([A-Za-z]+)/$ /cat/play/$1.html [L]

Will handle all of them.

Now, if you throw in some other URLs:

…mod_rewrite won’t know that they are meant to go to the “rest” directory. It will send them to the “play” directory because that’s the only one it knows about.

If there is only one parameter in the URL, then that’s the only one mod_rewrite can make decisions based on.

If you add a “category” parameter, then it could make that decision:


RewriteRule ^play/([A-Za-z]+)/$ /cat/play/$1.html [L]
RewriteRule ^rest/([A-Za-z]+)/$ /cat/rest/$1.html [L]

Are we talking about the same thing, or am I mixed up about your question?