如何删除.php扩展名并使用htaccess添加斜杠
问题描述:
I'm trying to put together some .htaccess
code that will turn example.com/login.php/register.php
into example.com/login/register
. I've tried varous approaches, but each hasn't worked quite right, from 500 [server] errors on subfolders to issues with the trailing slash, etc...
我正在尝试将一些 .htaccess code>代码整理成
example.com/login.php/register.php code>进入
example.com/login/register code>。 我尝试了各种各样的方法,但每个方法都没有用,从子文件夹上的500 [server]错误到尾部斜杠的问题等等...... p>
div>
答
first of all example.com/login.php/register.php is not a valid URL at all, first fix the URL and then
TRY ( this will rewrite /register.php
URL into /register
)
#mod_rewrite
RewriteEngine on
RewriteBase /[project_root_folder_name]/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^register/?$ register.php [NC]