本文介绍了查询字符串和放大器;国防部重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是太缺乏经验与改写(不是高手要么,虽然),所以我希望Somone的也许能帮助我。

I'm not too inexperienced with ReWrite (not a master either, though) so I was hoping somone might be able to help me.

RewriteRule ^$ index.php?page=home [NC]
RewriteRule ^adm$ index.php?page=adm_home [NC]
RewriteRule ^adm/stats index.php?page=adm_stats [NC]

以上是我的.htaccess文件的一个片段。正如你所看到的,当有人访问 http://www.example.com/adirectory/ 它实际上呼吁的index.php?页=家庭,同样的,如果有人去 http://www.example.com / adirectory / ADM / 它仍然在adirectory打电话的index.php?网页= adm_home。

Above is a snippet of my .htaccess file. As you can see, when someone visits http://www.example.com/adirectory/ it actually calls on index.php?page=home, similarly if someone goes to http://www.example.com/adirectory/adm/ it will still call index.php?page=adm_home within the "adirectory".

我正在想实现的是:我希望能够在我的网页上展示的警报,而要做到这一点,我想简单地可以添加警告= n(其中n是一个数字),因此有重定向的index.php页面=家庭及放大器;警报= N

What I'm wanting to achieve is this: I want to be able to display alerts on my pages, and to do this I want to simply be able to add alert=n (where n is a number) and thus have the redirect as index.php?page=home&alert=n

不过,我不知道如何可以做到这一点,正则表达式是混淆了我。寻求你的帮助。

However, I can't understand how this can be done, regex is confusing me. Seeking your help.

推荐答案

您可以设置的自动追加最初请求的查询字符串到新的:

You can set the QSA flag to automatically append the originally requested query string to the new one:

RewriteRule ^$ index.php?page=home [L,QSA]
RewriteRule ^adm$ index.php?page=adm_home [L,QSA]
RewriteRule ^adm/stats$ index.php?page=adm_stats [L,QSA]

这篇关于查询字符串和放大器;国防部重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 02:32