简体   繁体   English

快速ModRewrite和GET问题

[英]Quick ModRewrite and GET question

I'm trying to return a success notice if the $_GET['success'] is set. 我尝试返回成功通知,如果设置了$ _GET ['success']。 It works fine if I input it like this: mail?inbox&success 如果我这样输入,效果很好:mail?inbox&success

But I'm trying to make it work if I input it like this: mail/inbox/success or mail/inbox&success 但是,如果我这样输入,我试图使其工作:mail / inbox / success或mail / inbox&success

I'm not very experienced with mod_rewrite and I havent found a solution yet so I'm asking here. 我对mod_rewrite不太了解,还没有找到解决方案,所以我在这里问。 How would I get it to work with the examples above? 我如何将其与上述示例配合使用? This is what the .htaccess looks like right now: 这就是.htaccess现在的样子:

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

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. 在第一个规则之前也应该这样做,但是仅在这种情况下,并且可能会影响其他规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM