[英]How to remove .php extension and add slash with htaccess
I'm trying to put together some .htaccess
code that will turn example.com/login.php/register.php
into example.com/login/register
. 我正在尝试放在一起一些
.htaccess
代码,这些代码会将example.com/login.php/register.php
变成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... 我尝试了各种方法,但是每种方法都工作不正确,从子文件夹上的500个[服务器]错误到斜杠等问题,等等。
first of all example.com/login.php/register.php is not a valid URL at all, first fix the URL and then 首先example.com/login.php/register.php根本不是有效的URL,首先修复该URL,然后
TRY ( this will rewrite /register.php
URL into /register
) 尝试(这会将
/register.php
URL重写为/register
)
#mod_rewrite
RewriteEngine on
RewriteBase /[project_root_folder_name]/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^register/?$ register.php [NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.