开发者

Regular expression for Url rewriting php

开发者 https://www.devze.com 2023-04-01 19:11 出处:网络
I\'m using URL rewriting with Wamp but I don\'t find the correct regex for my needs. I\'d like to transform http://localhost/site_artisans/site_artisans/peintre-annecy.php in http://localhost/site_ar

I'm using URL rewriting with Wamp but I don't find the correct regex for my needs.

I'd like to transform http://localhost/site_artisans/site_artisans/peintre-annecy.php in http://localhost/site_artisans/site_artisanspeintre-annecy.php (remove the slash between site_artisans/site_artisans and whatever is after).

I thought of :

RewriteEngine on
RewriteRule .*site_artisans/site_artisans/.* site_artisans/site_artisans [L]

(Unknown number of characters before and after and sl开发者_StackOverflow社区ash removed).

But this doesn't work.


Try

RewriteEngine on
RewriteRule .*site_artisans/site_artisans/(.*) site_artisans/site_artisans$1 [L]

I tested it on http://martinmelin.se/rewrite-rule-tester/ and I believe the result is what you want.


Try this:

RewriteEngine on
RewriteRule .*site_artisans/(site_artisans/.*) site_artisans/$1 [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号