Kraffs
Kraffs

Reputation: 533

Quick ModRewrite and GET question

I'm trying to return a success notice if the $_GET['success'] is set. It works fine if I input it like this: mail?inbox&success

But I'm trying to make it work if I input it like this: mail/inbox/success or mail/inbox&success

I'm not very experienced with mod_rewrite and I havent found a solution yet so I'm asking here. How would I get it to work with the examples above? This is what the .htaccess looks like right now:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^user/([^/]*)$ /userinfo?name=$1 [L]
RewriteRule ^items/([^/]*)$ /items?weapon=$1 [L]
RewriteRule ^mail/inbox /mail?inbox [L]
RewriteRule mail/(.*)/(.*)$ /mail?read=$2

Upvotes: 0

Views: 47

Answers (1)

Simon
Simon

Reputation: 4585

You could change

RewriteRule ^mail/inbox/ /mail?inbox [L]

to

RewriteRule ^mail/inbox/(.*) /mail?inbox&$1 [L]

Depends on what other combinations you want to rewrite. Adding the line

RewriteRule ^mail/inbox/success /mail?inbox&success [L]

before the first rule should do it also, but only for this one case and may influence other rules.

Upvotes: 1

Related Questions