[英]Url redirection issue using .htaccess and php
我正在尝试使用.htaccess重写URL。 我尝试了几种解决方案来达到所需的URL,但无法弄清楚。 谁能帮忙。
原始网址
http://localhost/view_retailer.php?id=<storename>
使用.htaccess重写的url
http://localhost/view_retailer?id=<storename>
所需网址
http://localhost/store/<storename>
您可以在根.htaccess中使用以下2条规则:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /view_retailer(?:\.php)?\?id=([^\s&]+) [NC]
RewriteRule ^ /store/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^store/([^/]+)/?$ view_retailer.php?id=$1 [L,QSA,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.