我想从 URL 中删除网页扩展,有人给了我 .htaccess 的代码。但是当我打开重写模块时它可以在 localhost一些访问 example.com/cool.php 到 example.com/cool.... 以及关于 godaddy 重写模块的帮助 我联系了他们,他们还没有回复我。下面是那个人给我的代码..谢谢
RewriteEngine On
RewriteBase /
# remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]