简体   繁体   中英

htaccess rewrite rule for url parts

My url looks lik:

http://example/en/account/register

I want to catch with regexp this url

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

In this rule I want have all url that contain 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:

  1. To catch 2 letter language use \\w{2} not \\w{2}+
  2. You cannot use anchor ^ in the middle of your regex as it means start of input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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