【发布时间】:2014-12-29 10:57:29
【问题描述】:
我想重写我的网址
发件人:
收件人:
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 中获得 token 时,它就不起作用了。
对于这种情况,正确的 .htaccess 代码是什么?
【问题讨论】:
标签: php .htaccess mod-rewrite url-rewriting