我想在从文件中删除.php之后添加url的斜杠结尾。 对于前者www.xyz.com/abc /
我使用了以下.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php**strong text**
答案 0 :(得分:1)
你可能想要这个
RewriteEngine On
# where the .htaccess file is located (public path from document_root)
RewriteBase /subdir/path/based/on/document_root
# does not apply to existing directories
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite dir-like urls to php script and END rewriting to avoid infinite loop
RewriteRule (.*)/ $1.php [END]
# apply to existing files only
RewriteCond %{REQUEST_FILENAME} -f
# browser redirect to canonical URL
RewriteRule (.*)\.php$ $1/ [L,R=301]