我需要帮助乌拉圭回合对于给定的主题。 我第一次玩htaccess的规则生活。
I need ur help for given subject. I am playing with htaccess rules first time in life.
下面是场景 -
我要重定向的URL -
i want to redirect the urls -
www.abc/var1 www.abc/var2要follwing网址 -
to follwing urls -
www.abc/index.php?u=var1 www.abc/index.php?u=var2在这种情况下,值VAR1&安培; VAR2可以是任何东西(例如,将只包含字母数字字符的字符串。)
In this case the values var1 & var2 can be anything (i.e. string which will contain only alphanumeric characters.)
还有一件事 -
我想跳过这个规则,如果URL是 -
I want to skip this rule if the url is -
www.abc/SKIPME
请帮我写这个规则!
问候, 沙湖!
推荐答案您会过得更好定义的URI模式,它会告诉你什么时候事情会被改写。例如...
You would be better off defining a URI schema that tells you when something WILL be rewritten. For example...
www.abc/site/var1 www.abc/site/var2
这样一来,就可以保证你永远只能应用规则,如果伪网站/目录浏览,并不会影响任何其他URI。这是一个基于上面的架构重写规则。
That way, you can ensure you only ever apply the rule if the psuedo "site/" directory is browsed and not affect any other URI. This is the rewrite rule based on the above schema.
RewriteEngine on RewriteRule ^site/([^/\.]+)/?$ index.php?u=$1 [L,NC,QSA]
任何其他地址,比/site/.../等将不受这一规则,这意味着你不必担心设置一些地址可以被避免。这让事情尽可能的简单。
Any other address, other than "/site/.../" would be unaffected by this rule, which means you don't need to worry about setting some addresses to be avoided. This keeps things as simple as possible.
您不必使用网站 - 你可以使用任何名字你的目的,符合
You don't have to use "site" - you can use whatever name fits your purpose.
更多推荐
帮助有关htaccess的动态重定向规则
发布评论