[ACCEPTED]-How to reference the current directory from .htaccess using mod_rewrite?-mod-rewrite
I was having a similar problem, but found 11 that simply leaving off the root '/' resulted 10 in my test web server (xampp on windows) serving 9 a URL similar to:
Not perfect. My solution 8 is to use a RewriteCond to extract the path 7 from REQUEST_URI. Here's an example for 6 removing the unwanted "index.php"s 5 from the end of the URL:
RewriteCond %{REQUEST_URI} ^(.*)/index.php$
RewriteRule index.php %1/ [r=301,L]
Note: the percent 4 sign in "%1/", rather than a dollar 3 sign.
%1-%9 gets the patterns from the last 2 matched RewriteCond, $1-$9 gets the patterns 1 from the RewriteRule.
See: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond
Cheers :)
Turns out that it does matter whether I 5 put a leading / in front of index.php or 4 not. By leaving it off, the script works 3 correctly. I had been testing with the R 2 flag which was using physical directories 1 on the redirect.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.