[英]how to achieve url rewrite in htaccess file
我正在尝试在htaccess文件中重写url。
我在htaccess文件中编写了以下代码。 但这不起作用。
这是我的代码:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]
如何以给定格式编写以下网址
http://www.site.com/play/player.php?/id=9 to http://www.site.com/play/player/9
我怎样才能做到这一点。
将此.htaccess放在/play/.htaccess
:
RewriteEngine On
RewriteBase /play/
RewriteRule ^([^/.]+)/([0-9]+)/?$ $1.php?id=$2 [L,QSA]
您在问题中的规则只会匹配以.htm结尾的请求-您想要的可能类似于:
RewriteRule ^play/player/(.*)$ /play/player.php?id=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.