PDA

View Full Version : htaccess mod rewrite



Templarian
October 4th, 2007, 09:05 PM
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/(.*) index.php?a=$1 [nc]
RewriteRule ^(.*) index.php?p=$1 [nc]

//so it works with
domain.com/admin/edit
domain.com/index

Whats the correct way to do this basically if the admin/ is found I don't want it to run the url rewrite done for the second rule. is there a way to write

RewriteRule ^([ ]+) index.php?p=$1 [nc]

I don't know what I would put in the [] to say not include the "/" but all other characters work.

Thanks. Very stuck on this.

Templarian
October 5th, 2007, 02:28 PM
nvm got it to work, well sort of read down further.

Esherido
October 5th, 2007, 02:35 PM
I can't think of anything besides writing logic into index.php to ignore index.php?p=admin/something.

MTsoul
October 5th, 2007, 03:02 PM
I don't remember how exactly it works, but does the second rule rewrite the first rule? So if you to go /admin/, what url do you get? If it does not overwrite, what you have is fine. If it does overwrite, simply put the first rule after the second rule so it'll overwrite to the one you want.

Templarian
October 5th, 2007, 03:28 PM
Answer: Shortened as much as i could.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/.]+)$ /admin/$1/ [R]
RewriteRule ^admin/([^/.]+)/?$ /?a=$1 [L]
RewriteRule ^([^/.]+)$ /$1/ [R]
RewriteRule ^([^/.]+)/?$ /?p=$1 [L]