Home > OS >  Apache mod_rewrite regexp
Apache mod_rewrite regexp

Time:07-20

Can anyone tell me the Apache mod_rewrite code for this:

messages/reply/361568/T2kgdHVk|byBiZW0gPyAgOik

My try that gives 404 error:

  RewriteCond "%{REQUEST_URI}"  messages\/reply\/(\d )\/(.*)$
  RewriteRule  messages\/reply\/(\d )\/(.*)$    /index.php?o=m&t=reply&mid=$1&det=$2 

CodePudding user response:

You can just use:

RewriteRule ^messages/(reply)/(\d )/(. )$ index.php?o=m&t=$1&mid=$2&det=$3 [L,QSA,NC]

There is not need to use redundant RewriteCond "%{REQUEST_URI}" as we can match and capture REQUEST_URI segments from RewriteRule itself.

  • Related