简体   繁体   English

网址部分的htaccess重写规则

[英]htaccess rewrite rule for url parts

My url looks lik: 我的网址看起来不错:

http://example/en/account/register

I want to catch with regexp this url 我想用正则表达式捕获此URL

RewriteRule ^(\w{2}+)/(^account)$ 

In this rule I want have all url that contain http://example/en/account/ 在此规则中,我希望所有包含http://example/en/account/网址

I can't found where is problem in my regexp, because this regexp is not correct for that url ... 我在我的正则表达式中找不到问题所在,因为此正则表达式不适用于该网址...

You can use this pattern: 您可以使用以下模式:

RewriteRule ^(\w{2})/(account)/?$ your-handler [L] 

2 points about your regex: 关于正则表达式的2点:

  1. To catch 2 letter language use \\w{2} not \\w{2}+ 要使用2个字母的语言,请使用\\w{2}而不是\\w{2}+
  2. You cannot use anchor ^ in the middle of your regex as it means start of input. 您不能在正则表达式的中间使用锚^ ,因为这意味着开始输入。

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

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