Hi! I'm having a problem with apache mod rewrite, I'm noob as a man can be This is the behavior that I need to achieve: When someone enters www.mysite.com/gallery/ (with or without trailing slash), it should be redirected to www.mysite.com/index.php?view=gallery and I have solved that part with this rule rewriteRule ^([^./]+)/?$ .php?view=$1 [L] But, there should also be a possibility for users to directly enter gallery ID with a URL like this one: www.mysite.com/gallery/5/ which then should be redirected to www.mysite.com/index.php?view=gallery&id=5. And that's where my problem is. This is the rule that I'm currently stuck with... rewriteRule ^([^/]+/)?([^./]+)/?$ index.php?view=$1&id=$2 [L] It works fine except one small thing....as my first parameter I get the name of it but with trailing slash added (for example "gallery/" ), but I'd like to have that parameter without slash at the end. So, is there anyone who could help me out with this one, or I will have to strip that slash in php (which I'd like to escape if possible) Thanks for any help!
try this RewriteEngine On RewriteRule ^([^/]*)$ /index.php?view=$1 [L] RewriteRule ^([^/]*)/([^/]*)$ /index.php?view=$1&id=$2 [L] Code (markup):