简体   繁体   English

在新的Rewrite-URL中删除不需要的Get-Parameter

[英]Removing unwanted Get-Parameter in new Rewrite-URL

I have the following .htaccess-file: 我有以下.htaccess文件:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ((^((/)*admin(/)+).*)|(^admin$)) $0 [NS]
    RewriteRule ^((?!\.).)*$ "system/scripts/startPageProcess.php?slug=$0" [NS]
</IfModule>

If theres a URL called starting with "admin/" or being equal to "admin", there should be no redirection. 如果存在一个以“ admin /”开头或等于“ admin”的URL,则不应进行重定向。 If the URL is differend, startPageProcess.php should be called with the URL as the "slug"-Get-Parameter (for example "asdf" redirects to "system/scripts/startPageProcess.php?slug=asdf"). 如果URL不同,则应使用URL作为“ slug” -Get-Parameter调用startPageProcess.php(例如,“ asdf”重定向到“ system / scripts / startPageProcess.php?slug = asdf”)。 This works so far. 到目前为止,该方法有效。

Now there is the following problem: If I call "admin", there is no redirection - so far, so good - but the URL shown in the browser changes to: "admin/?slug=admin" and I have no idea why. 现在存在以下问题:如果我叫“ admin”,则没有重定向-到目前为止很好-但是浏览器中显示的URL更改为:“ admin /?slug = admin”,我不知道为什么。

I'm really not an .htaccess-expert, so I don't know why this happens, how you can fix this, or if you could make the whole thing easier. 我实际上不是.htaccess专家,所以我不知道为什么会这样,如何解决此问题,或者是否可以使整个过程变得更容易。 So please help. 所以请帮忙。

You need to add a last rule flag so the admin rule would be 您需要添加最后一个规则标志,以便管理规则为

RewriteRule ((^((/) admin(/)+). )|(^admin$)) $0 [NS, L] RewriteRule(((^((/) admin(/)+)。 )|((^ admin $))$ 0 [NS,L]

Have your rules like this: 有这样的规则:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^admin(/.*)?$ - [L]
    RewriteRule ^([^./]+)/?$ system/scripts/startPageProcess.php?slug=$1 [L,QSA]
</IfModule>

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

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