Is there a way to have the mod_rewrite rules in my .htaccess
file take effect before PHP behind fcgi sees the request?
I have an email validation link that I want to redirect from root to the login page before PHP marks it in the database as confirmed.
These are the rules I have in my .htaccess
, and they work, but PHP sees the request before the rewrite rule takes effect.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} activation_key=
RewriteRule ^$ /login [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
When PHP sees a request that contains the activation_key
query string, it marks the user as activated. If the user is already activated, the page will show an "Unknown validation link" error.
With these rewrite rules the request redirects to the /login
page and displays the error, indicating - I assume - that PHP had already seen the request.
This is the mod_fastcgi config:
<IfModule mod_fastcgi.c>
DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>