htaccess mod_rewrite question

He has: 14 posts

Joined: Sep 2005

RewriteEngine on
RewriteRule ^login$ /login.php
RewriteRule ^logout$ /logout.php
RewriteRule ^[A-Za-z0-9_]*$ /index.php?user=$1
'

Based on the .htaccess code above, I would like to change it so that
when the browser points to:
1. http://example_host.com/bob
- the rewrite rule: RewriteRule ^[A-Za-z0-9_]*$ /index.php?user=$1 is in effect.

2. http://example_host.com/login
- the rewrite rule: RewriteRule ^login$ /login.php is in effect.

How would I change the .htaccess code (using RewriteCond???). If it is using RewriteCond, can someone please show me how to use it in this situation?

Thanks in advance!

Busy's picture

He has: 6,151 posts

Joined: May 2001

place [L] after each one

RewriteEngine on
RewriteRule ^login$ /login.php [L]
RewriteRule ^logout$ /logout.php [L]
RewriteRule ^[A-Za-z0-9_]*$ /index.php?user=$1 [L]

you said login was in effect, if they dont work remove the slash, like:
RewriteRule ^login$ login.php [L]
You might find the rewrite not always working as login is different to login/
The dollar signs means ends with, so you could double up the rule (one with and one without slash) or remove the dollar sign so it just starts with login, but then login is the same as logintomypage

He has: 14 posts

Joined: Sep 2005

Thanks very much!

That worked exactly like I wanted it to.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.