Forum Moderators: phranque
I have an .htaccess file defined for performing some pretty basic mod_rewrite work:
-------------------------
RewriteEngine On
# If request is not for html, htm, php, txt, gif, jpeg, jpg, or png files
RewriteCond %{REQUEST_URI}!\.(html?¦php¦txt¦gif¦jpe?g¦png¦css)$
# and if the current query string does not include an aff id
RewriteCond %{QUERY_STRING}!IBA=
# and the requested resource does not exist as a directory
RewriteCond %{REQUEST_FILENAME}!-d
# append aff query string to URL and any existing query string
RewriteRule (.*) /shop.php?username=$1 [QSA,L]
-------------------------
I am confused as to why this script still executes shop.php (last line) even when the request is for an actual php file - shouldn't the RewriteRule be skipped when a RewriteCond is met?
Any help appreciated, I'm pretty new to this.
Brendan
Welcome to WebmasterWorld!
Are you hosted with a commercial hosting service, or self-hosted?
Are you using Apache 1.x or Apache 2.x?
The reason I ask is that it's possible that the LoadModule list in httpd.conf is incorrectly ordered in Apache 1.x, with the php module appearing after mod_rewrite. In this case, php will execute before mod_rewrite, and your rule won't be processed for php requests.
This is quite a common mistake, since one would assume it's OK to add php on at the end of the list. But it fact, this prevents any other module --such as mod_auth for login checking-- from running for php requests.
The solution would be to load the php module before loading mod_rewrite.
This is just a guess, because your code looks OK. If it doesn't apply, then we'll need more info.
Jim
I'm running on a leased Linux server - and I have SSH root access, but am pretty new to linux.
Looking through the primary httpd.conf file, I cant see a loadmodule entry for php, does this mean it's Apache 2?
I also see reference to 'http://httpd.apache.org/docs-2.0/' at the top of the file, which I assume means the server is running apache 2.