akajash
akajash

Reputation: 107

Problem Rewriting the URL using .htaccess

I've built a site using php, There is a problem while rewriting the URL of the site.

The URL : http://example.com/profile.php?user=jash The URL I want: http://example.com/jash

I've used the following rewrite rule in .htacccess:

RewriteRule ^([a-zA-Z0-9_-]+) profile.php?user=$1 [NC,L]

This works fine for me, but the real problem starts here, when I hit : http://example.com/login.php , it should redirect me to login.php instead it checks for the users and displayed too many redirects. Can I get a fix?

Upvotes: 1

Views: 29

Answers (1)

jeprubio
jeprubio

Reputation: 18002

Try to ignore all files and directories from that rewrite rule, place this at the top of that rule:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

Upvotes: 2

Related Questions