简体   繁体   中英

how to achieve url rewrite in htaccess file

I am trying to rewrite url in htaccess file.

I wrote the following code in htaccess file. but it doesn't work.

Here is my Code :

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC] 

How can i write following url in given format

http://www.site.com/play/player.php?/id=9 to http://www.site.com/play/player/9

How can i achieve this.

Place this .htaccess in /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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM