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

#176637
ewisely
Participant

Hi traq,

I’m having problem doing 301 redirects. As I have just changed my site’s url structure from:

mysite.com/q/sleep-rest.htm to mysite.com/sleep-rest/
mysite.com/q/play-study.htm to mysite.com/play-study/
and so on…

I need to redirect them all with just a single line of code. So, I do this:

RewriteRule ^q/([a-zA-Z0-9_-]+)\.htm$ /$1/ [R=301,L]
<code></code>

But I got a “redirect loop” error. What’s wrong with my code? Appreciate your help. Thanks.