last day (15 days later) » 

4:41 PM
2
A: 301 redirect URLs that are also being rewritten

anubhavaYou need a new redirect rule before this rule: RewriteEngine On RewriteCond $0#%{REQUEST_URI} ^([^#]*)#(.*)\1$ RewriteRule ^.*$ - [E=BASE:%2] RewriteCond %{THE_REQUEST} /index\.php [NC] RewriteRule ^index\.php/(.+)$ %{ENV:BASE}$1 [L,R=302,NC,NE] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond...

 
Hmm, I saw your answer in another question but it doesn't seem to be working for me. If I have ^ at the beginning of the RewriteRule pattern, isn't that going to try to match the URL from the very beginning?
This works for something like http://localhost/index.php/blah, but not http://localhost/site1/index.php/blah (assuming that my .htaccess file is in the /site1 directory relative to my document root).
 
If your .htaccess is in site1 then you need a RewriteBase (see updated rule).
 
Isn't there a way to do a regex match of the base? Otherwise, it will require every user of my software to configure their .htaccess individually. I don't want to add that extra level of complexity.
 
ok check updated rules, it will generate rewrite base dynamically
 
Hmm, still no luck. I'm running Apache 2.4.4, if that is any help. Can we discuss in chat?
 
4:41 PM
I've tested this run in Apache 2.4.4 and in subdirectory. http://localhost/site/index.php/account/login gets redirected to http://localhost/site/account/login
 
Oh, so it does!
by the way, thanks so much for taking the time to help me with this.
 
Do you want http://localhost/site/index.php => http://localhost/site/ also?
 
yup
 
ok check updated answer
 
wow, beautiful!
 
4:55 PM
thanks
 
and it plays nicely with my other rewrite rules, too!
 
yes it will
 
you might want to submit this to github.com/phanan/htaccess
generating rewrite base dynamically
 
ah good idea, I will certainly do that
 
let me know if there is anything I can do for you in the future.
oh and, I guess I should change it to a 301 redirect for deployment, right?
 
5:01 PM
yes 302 was for testing purpose only
 
browsers love to cache those 301's, I guess.
 
yes right
 
5:44 PM
take care & bye
 

last day (15 days later) »