简体   繁体   中英

How to add trailing slash in every URL?

i'm creating a dynamic PHP Blog site, where i have 2 type of url, in where one is having trailing slash and another one is no trailing slash. i want to create trailing slash in each every single url.

this below url is working properly trailing slash at the end...

http://example.com/category/title-of-the-article/

When i navigate to category it's no trailing slash i want to make trailing slash at the end

http://example.com/category

i want

http://example.com/category/

htaccess code

RewriteEngine On
RewriteBase /

RewriteRule ^home index.php [NC,L]

RewriteRule ^([0-9a-zA-Z]+)$ archive.php?category=$1 [NC,L] 

RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+) post.php?category=$1&url=$2 [NC,L]

In above htaccess code post.php is working fine.... article.php is not working.

please help me to make it possible....

Bro Htaccess is a thing that we need to debug when we face issue if you put snippet code than we can debug it but as a reader its hard to identify .

but try this one i thing that will solve your problem

RewriteRule ^([0-9a-zA-Z]+)/?$ archive.php?category=$1 [QSA,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