Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess重写相似的主角,但不同的模式都将进行相同的替换_.htaccess_Url Rewriting - Fatal编程技术网

.htaccess htaccess重写相似的主角,但不同的模式都将进行相同的替换

.htaccess htaccess重写相似的主角,但不同的模式都将进行相同的替换,.htaccess,url-rewriting,.htaccess,Url Rewriting,我有一组URI: RewriteRule ^/?products|Main/abcd_?blue_?small.*$ /scrpts/abcd_blues_small.php [NC,R,L] RewriteRule ^/?products|Main/abcd_?red_?big.*$ /scrpts/abcd_red.big.php [NC,R,L] RewriteRule ^/?products|Main/abcd_?green.*$ /scrpts/abcd_green

我有一组URI:

RewriteRule ^/?products|Main/abcd_?blue_?small.*$ /scrpts/abcd_blues_small.php      [NC,R,L]
RewriteRule ^/?products|Main/abcd_?red_?big.*$ /scrpts/abcd_red.big.php      [NC,R,L]
RewriteRule ^/?products|Main/abcd_?green.*$ /scrpts/abcd_green.php      [NC,R,L]
RewriteRule ^/?products|Main/abcd_?yellow_?large.*$ /scrpts/abcd_yellow.php      [NC,R,L]
在阅读了许多帖子,尝试了许多不同的规则和条件之后,我错过了一些东西,没有按照需要让规则发挥作用。我真的需要帮助

使用这些链接进行测试将显示所有测试都将进行相同的替换(/scrpts/abcd_blues_small.php),这是每个测试都应进行不同替换时的第一个重写规则:

/Products/abcd_blue_small.asp
/Products/abcdbluesmall.html
/Main/abcdbluesmall.php
/Main/abcd_blue_small.asp
/Products/abcdredbig.html
/Products/abcdredbig.html  
/Products/abcd_green.asp
/Products/abcd_green.php  
/Products/abcdyellowlarge.asp
/Products/abcdyellowlarge.php  
使用“/Products/abcdyellowlarge.asp”测试时,重写日志如下所示-

127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (3) [perdir /Users/santa/Sites/www.dartpro.com/] add path info postfix: /Users/santa/Sites/www.dartpro.com/Products -> /Users/santa/Sites/www.dartpro.com/Products/abcdyellowlarge.asp
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (3) [perdir /Users/santa/Sites/www.dartpro.com/] strip per-dir prefix: /Users/santa/Sites/www.dartpro.com/Products/abcdyellowlarge.asp -> Products/abcdyellowlarge.asp
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (3) [perdir /Users/santa/Sites/www.dartpro.com/] applying pattern '^/?products|Main/abcd_?blue_?small.*$' to uri 'Products/abcdyellowlarge.asp'
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (2) [perdir /Users/santa/Sites/www.dartpro.com/] rewrite 'Products/abcdyellowlarge.asp' -> '/scrpts/abcd_blues_small.php'
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (2) [perdir /Users/santa/Sites/www.dartpro.com/] explicitly forcing redirect with http://dart/scrpts/abcd_blues_small.php
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (1) [perdir /Users/santa/Sites/www.dartpro.com/] escaping http://dart/scrpts/abcd_blues_small.php for redirect
127.0.0.1 - - [08/Oct/2016:16:46:33 --0500] [dart/sid#7fb5728385b8][rid#7fb572a796a0/initial] (1) [perdir /Users/santa/Sites/www.dartpro.com/] redirect to http://dart/scrpts/abcd_blues_small.php [REDIRECT/302]
有人能帮我把这些不同的图案换成不同的替代品吗?先谢谢你

试试:

RewriteRule ^/?(?:products|Main)/abcd_?blue_?small.*$ /scrpts/abcd_blues_small.php      [NC,R,L]
RewriteRule ^/?(?:products|Main)/abcd_?red_?big.*$ /scrpts/abcd_red.big.php      [NC,R,L]
RewriteRule ^/?(?:products|Main)/abcd_?green.*$ /scrpts/abcd_green.php      [NC,R,L]
RewriteRule ^/?(?:products|Main)/abcd_?yellow_?large.*$ /scrpts/abcd_yellow.php      [NC,R,L]
因为现在您使用第一条规则进行测试:
^/?产品



Main/abcd_?blue_?small.$

似乎可以完美地配合我的所有测试!但我一点也不明白为什么这种改变能让它起作用——在模式中使用(?:products | Main)而不仅仅是“products | Main”,你能简单地解释一下吗

多谢各位