[英]mod_rewrite - rule according to url path
I am pretty weak at regex, and I need help with a mod_rewrite rule that does the following: 我在regex方面非常虚弱,我需要有关执行以下操作的mod_rewrite规则的帮助:
Both directories a and b are under the same root directory of course. 目录a和b当然都在同一根目录下。
I managed to do number 2, but I have no idea how to include rule 1. 我设法做到了2,但我不知道如何包括规则1。
You can use the following : 您可以使用以下内容:
RewriteEngine on
#--if url is just the domain name--#
#--rewrite to /a/index.php--#
RewriteRule ^$ /a/index.php [NC,L]
#--if it contains path--#
#--rewrite to /b/index.php?id=path
RewriteRule ^((?!b).+)$ /b/index.php?id=$1 [NC,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.