简体   繁体   English

我的.htaccess文件不会删除.php URL

[英]My .htaccess file wont remove .php URL

I have a question about my .htaccess file, it won't show the file, when typing domain.com/about, instead of domain.com/about.php 我对我的.htaccess文件有疑问,当键入domain.com/about而不是domain.com/about.php时,它不会显示该文件

Here is my .htaccess code (it works on localhost), i am using ubuntu and apache2 webserver 这是我的.htaccess代码(适用于localhost),我正在使用ubuntu和apache2网络服务器

RewriteEngine on

# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]

# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]

use 采用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM