alchuang
alchuang

Reputation: 3571

apache rewrite specific htaccess redirections

I have problem with my .htaccess redirections.

Say I want to change

http://www.domain.com/login.php

into

http://www.domain.com/login 

or

http://www.domain.com/login/ 

my .htaccess works with "www.domain.com/login"

but when using "www.domain.com/login/" (with a slash in the end) the css and images get all messed.

my .htaccess is as follows

# Turns on Rewrite Engine
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteRule ^login/?$ login.php [NC,QSA,L]
RewriteRule ^loginFailed/?$ failed.php [NC,QSA,L]

Also I have a login.php that directs to failed.php when the user enters the wrong username/password combination. I tried setting it up using the same method.

But when I tested starting from http://www.domain.com/login entering a wrong combination directs me to

http://www.domain.com/failed.php

instead of the desired http://www.domain.com/loginFailed

how can I solve this problem.

Much appreciated!!

Upvotes: 1

Views: 112

Answers (1)

Olivier Pons
Olivier Pons

Reputation: 15778

The problem seems to be not in your RewriteRules, but in your Php code. Are you sure that the redirection when the login fails, in your Php code is for sure loginFailed (instead of failed.php)?

I would suggest to check you Php code first ;)

Upvotes: 2

Related Questions