Home › Forums › Other › How to remove subdirectories using mod_rewrite in .htaccess › Reply To: How to remove subdirectories using mod_rewrite in .htaccess
July 28, 2014 at 9:18 pm
#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