的url:.htaccess的正则表达式trats
http://www.gamempire.it/hello-pc
http://www.gamempire.it/hello-ps3
我想他们301:http://www.gamempire.it/hello
但这不起作用:RewriteRule ^(.*)-(pc|ps3)(.*)$ /$1$2 [R=301,L]
感谢
的url:.htaccess的正则表达式trats
http://www.gamempire.it/hello-pc
http://www.gamempire.it/hello-ps3
我想他们301:http://www.gamempire.it/hello
但这不起作用:RewriteRule ^(.*)-(pc|ps3)(.*)$ /$1$2 [R=301,L]
感谢
实际上,您不需要捕获$2
并将其用于替换。
您可以使用
RewriteEngine On
RewriteRule ^([^-]*)-(?:pc|ps3)(.*)$ /$1$2 [NC,R=301,L]
你可以使用'.'而不是'[^ - ]'和IMO它更容易阅读 –
是的,这也可以工作,但只是为了效率因素,我用否定'[^ - ]' – anubhava
With'[^ - ]它不工作,与'。'是:)感谢很多 –
阐述 “不工作”。会发生什么? – Qtax