有没有办法制作一个基于php
的URL重写器?我想为我公司的 CMS 制作一个 URL 重写模块。
例如:
http://www.seacen.org/v2/content.php?id=32&lang=1.htm
自
http://www.seacen.org/v2/content/32/1
创建一个.htaccess
文件并将以下内容粘贴到其中
Options +FollowSymLinks
RewriteEngine on
RewriteRule content/(.*)/(.*)/ content.php?id=$1&lang=$2.html
您的mod_rewrite可能已启用,但如果没有:
- 如果您使用的是共享主机,请让您的主机支持人员为其启用你。
- 如果您在 VPS 上或在本地运行测试服务器,请取消注释httpd.conf
LoadModule rewrite_module modules/mod_rewrite.s
中的以下行