我正在运行Ubuntu 18.04服务器,而php版本是5.6
https://myurl its index.php
在点击其他链接时自动加载
https://myurl/deam
不能用php自动填充
https://myurl/dream.php 我通过ht访问做了一些事情,但不知道哪个代码阻止了我的ht访问code
当我现在用.php键入其工作时,我想要每当链接单击.php时自动填充它,我该怎么做?
答案 0 :(得分:1)
您可以将.htaccess与重写一起使用
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteCond %{REQUEST_FILENAME}\.php ^(.*)\.php(.*)$
RewriteRule .* %1.php?%2 [QSA]
答案 1 :(得分:0)
https://serverfault.com/a/531587
下次尝试所有答案对您有帮助
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]