Mod_Rewrite help

Hello there!

I am having a small issue that I am hoping one of you could help me fix quick.

Here are the contents of .htaccess:


Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ index.php?id=$1&name=$2 [L]

When I navigate to the following, it works

When I navigate to the following, it does NOT work:

It seems to be messing up when I have ANY forward slashes at the end…

Any ideas? thanks!

mag,

Add a /? before the end anchor.

Regards,

DK

Thanks, that sort of fixes the problem however when I add another directory for example:

The name variable gets replaced with “hehe” and doesn’t stay as “hello”

index.php?id=$1&name=$2

I wish id would stay as $1 and name would stay as $2…

Actually, when the url is requested with a forward slash at the end, it messes up the variables. I am echoing the ID and NAME variables on the page.

When the url ends with a forward slash those variables get messed up.

mag,

When you change the target URI like that, you are forcing yourself to write another mod_rewrite statement (to capture the second value for the redirect). Best to start over with a “specification” that is thought out and covers all the redirections you require.

IMHO, AVOID trailing slashes on your URIs as that not only affects the mod_rewrite but the relative links in the redirection’s target file.

Regards,

DK