.htaccess 从URL中删除.php并强制使用尾随斜杠/
我想使用.htaccess 从URL中删除.php并强制使用尾随斜杠/,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我想使用.htaccessmod_rewrite从我的所有文件中删除.php,并强制使用尾部斜杠/。但是,这只会导致我出现服务器错误。您要映射: http://sampledomain.ext/index/ -> http://sampledomain.ext/index.html 使用下面的.htaccess RewriteEngine On RewriteCond %{REQUEST_URI} ! \.php$ #Avoid real php page, do what you
.htaccess
mod_rewrite
从我的所有文件中删除.php
,并强制使用尾部斜杠/。但是,这只会导致我出现服务器错误。您要映射:
http://sampledomain.ext/index/ -> http://sampledomain.ext/index.html
使用下面的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} ! \.php$ #Avoid real php page, do what you want with them
RewriteCond %{REQUEST_URI} /$ #Ensure a final slash
RewriteRule ^(.*)$ $1.php #Add your extension
发送给David Wolever,他写了同样的东西
如果我能给出我的意见,那么在文件末尾强制使用/是有点奇怪的,因为文件号?可能是重复的