简体   繁体   中英

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 . 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...

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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