URL 重写(内部/外部转发器).htaccess


URL Rewriting (Internal/External Forwarders) .htaccess

我正在使用.htaccess进行URL重写。我目前的.htaccess代码是:

RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} 's/+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 ^fr/profil-des-transporteurs/([^/.]+)/?$ fr/transporter/transporterPublicProfile.php?profil=$1 [L,QSA,NC]

我的网址是 :

https://example.com/fr/profil-des-transporteurs/1927

当我将 .htaccess 文件放在目录中时DOCUMENT_ROOT它工作正常。

但是当我将相同的 .htaccess 文件放在真正的子目录中即/fr/时,它不起作用。

那么如果我想将 .htaccess 文件放在子目录中,即/fr/中,我该怎么办

/fr/.htaccess中使用这些规则:

RewriteEngine On
RewriteBase /fr/
# external redirect from actual URL to pretty one
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 [L,QSA,NC]

试试这个

RewriteEngine On
RewriteBase /fr