简体   繁体   English

如何忽略.htaccess重写URL中的“ /”

[英]How to ignore “/” in .htaccess re-write URL

I'm using .htaccess to hide the extensions of the my files which are in .php. 我正在使用.htaccess隐藏.php中我文件的扩展名。 Now suppose I've a file named "test.php" so If the user will enter " site.com/test " the file test.php will be opened. 现在假设我有一个名为“ test.php”的文件,因此如果用户输入“ site.com/test ”,则将打开文件test.php。 Now is there anyway in which even if the user writes " site.com/test/" (Slash / at the end of the URL ) is redirected or shows test.php? 现在无论如何,即使用户写了“ site.com/test/"末尾的斜杠/)也被重定向或显示test.php? I just want my site to ignore "/" at the end. 我只希望我的站点末尾忽略“ /”。

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)/$ /$1 [R=302]
RewriteRule ^test$ /test.php [L]

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

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