简体   繁体   English

如何在每个 URL 中添加尾部斜杠?

[英]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.我正在创建一个动态 PHP 博客站点,其中我有 2 种类型的 url,其中一个带有尾随斜杠,另一个没有尾随斜杠。 i want to create trailing slash in each every single url.我想在每个 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.在上面的 htaccess 代码post.php工作正常.... article.php不工作。

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 . Bro Htaccess 是我们在遇到问题时需要调试的东西,如果您将代码片段放在我们可以调试的范围内,但作为读者很难识别。

but try this one i thing that will solve your problem但试试这个能解决你问题的东西

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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