php - How to add trailing slash in every URL?
Get the solution ↓↓↓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 codepost.php
is working fine....article.php
is not working.
please help me to make it possible....
Answer
Solution:
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]
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.