简体   繁体   中英

How to remove a ".php" extension and add "/" at the end of the URL?

I would like to know how I can rewrite the following URL:

mydomain.com/service-demo.php

so that it can be accessed using one of:

mydomain.com/service-demo/
mydomain.com/service-demo
mydomain.com/service-demo.php

but always show this:

mydomain.com/service-demo/

create a new file (.htaccess ) in root folder and write this codes

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L] 

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