SystemX17
SystemX17

Reputation: 3715

htaccess RewriteRule being applied to images

I have an htaccess file utilising Rewrite Engine. I have attempted to set it up for individual pages to remove the .php extension.

I have found this being applied to an image called logout.png as well though. If the logout.png image is anywhere on the page, the user is logged out as if the logout.php page is being loaded somewhere in the background.

Here is my code:

RewriteEngine on
RewriteRule login login.php [L]
RewriteRule logout logout.php [L]

Is there something there I can change to make sure it's only applied to logout.php and not logout.png?

Upvotes: 1

Views: 43

Answers (2)

Richard
Richard

Reputation: 321

RewriteEngine on
RewriteRule login login.php
RewriteRule logout logout.php [L]
RewriteCond %{REQUEST_URI} !^/logout\.png$ [NC]

Try this?

If all things fail you can always rename files

Upvotes: 1

Jeff
Jeff

Reputation: 6953

If you want a regular expression to only match if the whole string matches wrap it in start and end delimiters:

RewriteRule ^logout$ logout.php [L]

Upvotes: 2

Related Questions