我想重写我的网址
从:
至:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
每当用户访问此URL时:
它看起来应该像这样:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
如果用户访问此URL:
https://example.com/fr/profil-des-transporteurs/1927/xnbjfgh4534534534dgfsdsd4
它应该保持原样.
到目前为止,我尝试过的是:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /fr/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+) [NC]
RewriteRule ^ fr/profil-des-transporteurs/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^profil-des-transporteurs/([^/.]+)/?(.*)$transporter/transporterPublicProfile.php?profil=$1&token=$2 [L,QSA,NC]
RewriteBase /
#RewriteRule ^/fr/shipper/(.*)$https://example.com/fr/$1 [L,R=301]
#RewriteRule ^login.php https://example.com/fr/shipper/login.php [L]
RewriteRule ^index\.html /index\.php......................
.htaccess中的问题是使用一个参数即profil可以正常工作
.但是当我在URL中获得令牌时,它不起作用.
在这种情况下正确的.htaccess代码是什么?
解决方法:
您需要为新参数设置新的规则集:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /fr/
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+)&token=([^\s&]+) [NC]
RewriteRule ^ profil-des-transporteurs/%1/%2? [R=302,L,NE]
RewriteCond %{THE_REQUEST} /fr/transporter/transporterPublicProfile\.php\?profil=([^\s&]+) [NC]
RewriteRule ^ profil-des-transporteurs/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^profil-des-transporteurs/([^/.]+)/([^/]+)/?$transporter/transporterPublicProfile.php?profil=$1&token=$2 [L,QSA,NC]
RewriteRule ^profil-des-transporteurs/([^/.]+)/?$transporter/transporterPublicProfile.php?profil=$1 [L,QSA,NC]
RewriteRule ^index\.html /index\.php [L]