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=somethingand 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.phpCan 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
精彩评论