这是预期的行为.之后,您需要通过PHP去除斜杠:$cl = trim( $_REQUEST['cl'], '/' );或者您将值分解为所有文件夹(如果在斜杠后有另一个名称)$cl = explode( '/', $_REQUEST['cl'] );my actual .htaccess isRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^([_0-9a-zA-Z-]+)? index.php?cl=$1 [L]and it works good when i type something like sub.domain.com/client1 (then i get the $cl variable in my php code properly). Problem is when i add a final trailing slash like sub.domain.com/client1/ then i get "client1/" in my var! How can i fix it? I know that the second condition in my htaccess looks for existing directories and skips the rewrite rule but there is no "client1" dir on my server! 解决方案 " Problem is when i add a final trailing slash like sub.domain.com/client1/ then i get "client1/" in my var!"That is the expected behavior. You need to strip the slash via PHP afterwards:$cl = trim( $_REQUEST['cl'], '/' );or you explode the value to get all folders (if there is another name following after the slash)$cl = explode( '/', $_REQUEST['cl'] ); 这篇关于URL目录作为带有htaccess的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 12:19