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

#176878
__
Participant

%{THE_REQUEST} is an Apache variable. Its value is the actual request line* from the HTTP request, unchanged by any rewrites (which is the reason it does not cause a redirect loop).

* for example:

GET /index.html HTTP/1.1

\w- is actually - (a dash) and \w (a “word” character; meaning alphanumerics or an underscore). Put together, [\w-] is just a shorter, more succinct way to write [a-zA-Z0-9_-].

%1 is a numbered backreference, just like $1 would be. The difference is that % backreferences refer to capture groups in RewriteConds, while $ backreferences refer to capture groups in RewriteRules.