Forums

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

#176725
__
Participant

Ahh… so, you’ve got one rule converting from form A→B, and then another converting from form B→A. See the infinite loop?

Instead of trying to match the legacy URL, use a rewrite condition to check against the actual request, so you only rewrite it when needed:

RewriteCond %{THE_REQUEST} /q/([\w-]+)\.htm
RewriteRule ^.*$ /%1 [R=301]

# follow with other rules as normal
RewriteRule ^([\w-]+)/?$ /q/$1.htm