我想从我网站的网址中删除我的任何文件扩展名。
例如:www.example.ml/dash/logins/sign.php 至:www.example / dash / logins / sign /
我做了一个谷歌的战利品,但没有一个答案对我有用。 我认为它没有用,因为在登录文件夹中我没有一个文件。还有很多其他文件,比如index.php,sign.php等。我必须将每个文件保存在单独的文件夹中,否则sing.php可以更改为签名/也会发生什么事情
sign.php?usercode = 1
它会转换为
符号/用户代码= 1
我alredy在.htaccess中有一些代码,所以请在提供此代码后给出答案
php_value display_errors Off
php_flag magic_quotes 1
php_flag magic_quotes_gpc 1
php_value mbstring.http_input auto
php_value date.timezone America/New_York
Options -Indexes
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.ml$ [NC]
RewriteRule ^(.*)$ https://www.example.ml/$1 [L,R=301]
答案 0 :(得分:0)
将此行添加到.htaccess文件中:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^\.]+)$ $1.php [NC,L]
答案 1 :(得分:0)
在.htaccess文件中使用此代码。它将重定向到php文件到非php版本。
# Turn on the rewrite engine
RewriteEngine on
# If the request doesn't end in .php (Case insensitive) continue processing rules
RewriteCond %{REQUEST_URI} !\.php$ [NC]
# If the request doesn't end in a slash continue processing the rules
RewriteCond %{REQUEST_URI} [^/]$
# Rewrite the request with a .php extension. L means this is the 'Last' rule
RewriteRule ^(.*)$ $1.php [L]
Tim Bielwa的例子 Remove .php extension with .htaccess