如何重写这样的链接
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]
答案 0 :(得分:1)
首先,您需要在vhost或<a [routerLink]="['/users/roles']" [queryParams]="{ stats: true }">
文件中添加此指令:
http.conf
这将允许编码的斜杠字符,即URL中的AllowEncodedSlashes On
。
您可以在站点根目录中使用这些规则.htaccess:
%2F
答案 1 :(得分:0)
你必须添加如下的角色规则。因为您的数据不仅仅是您在此处定义的网址中的数字形式。
RewriteRule ^content/([A-Za-z0-9-_]+)/?$ content.php?link=$1 [NC,L]