如何在子目录中删除扩展名.php

时间:2015-11-28 06:43:45

标签: apache .htaccess

我有问题要删除扩展名.php。例如,网址就像 https://www.domainname.net/dev/member.php。我只是想删除扩展名.php。有人可以帮助我。

2 个答案:

答案 0 :(得分:2)

在你的htaccess中试试这个:

 Options +Multiviews

然后您就可以在没有扩展名的情况下访问您的文件了。

答案 1 :(得分:1)

以下是.htaccess代码段,可帮助您将此代码放入.htaccess文件中:

# Apache Rewrite Rules
 <IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /

# Remove .php-extension from url
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^([^\.]+)/$ $1.php 

# End of Apache Rewrite Rules
 </IfModule>