开发者

htaccess rewrite rules

I have a url structure like this:

\http://www.domain.com/virtual_tours/virtual_name/

\http://www.domain.com/virtual_tours/virtual_name/virtual_tour_name-001.php?format=something

\http://www.domain.com/virtual_tours/virtual_name/virtual_tour_name-002.php?format=something

and I need to map those to the new urls that will look like this:

\http:/开发者_开发知识库/www.domain.com/virtual-tours/virtual-name.php

\http://www.domain.com/virtual-tours/virtual-name/virtual-tour-name-001.php

\http://www.domain.com/virtual-tours/virtual-name/virtual-tour-name-002.php

Can someone help me with the condition and rule for this?


I don't think that is good idea to perform something like str-replace inside .htaccess. Much more better and flexible method is to rewrite all URL you need to the php script and perform the REQUEST_URI parsing and URL routing inside via PHP code.


RewriteEngine On

RedirectMatch permanent ^/(virtual_tours)/(virtual_name)$ http://www.domain.com/virtual-tours/virtual-name.php

RedirectMatch permanent ^/(virtual_tours)/(virtual_name)/virtual_tour_name-(.*)\?.*$ http://www.domain.com/virtual-tours/virtual-tour-name-$1.php
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜