【发布时间】:2017-06-26 11:24:18
【问题描述】:
如何重写这样的链接
http://stanime.pe.hu/content.php?idf=15&link=Katsugeki--Touken+Ranbu
致http://stanime.pe.hu/15/Katsugeki--Touken+Ranbu
我使用 Urlencode 和 urldecode 对我的网址进行编码和解码
在使用 latin1_swedish_ci 的数据库排序中
所以,space 将替换为 + 和 / 替换为 %2f 等等......
这是我的 .htacces 代码
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+content\.php\?link=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ content.php?link=$1 [B,L,QSA]
【问题讨论】:
标签: php apache .htaccess mod-rewrite