Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从url中删除文件名为破折号(-)的.php扩展名?_Php_.htaccess - Fatal编程技术网

如何从url中删除文件名为破折号(-)的.php扩展名?

如何从url中删除文件名为破折号(-)的.php扩展名?,php,.htaccess,Php,.htaccess,使用以下.htaccess规则,我可以轻松地从文件名以index.php、account.php、login.php等开头的url中删除.php扩展名 但是 如果文件名以例如:how-to-work.php开头(注意破折号)则不会从url中删除.php扩展名 你能告诉我怎么做吗 .htaccess文件: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f Rewri

使用以下.htaccess规则,我可以轻松地从文件名以index.php、account.php、login.php等开头的url中删除.php扩展名

但是

如果文件名以例如:how-to-work.php开头(注意破折号)则不会从url中删除.php扩展名

你能告诉我怎么做吗

.htaccess文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

哎呀!它现在可以工作了:)还有一个问题:现在它显示的文件名没有任何.php扩展名,但是当我可以点击logo时,我指的是主页,它显示的是“www.myurl.com/index”。可以只显示:www.myurl.com吗?对我来说很好。