Rewritecond htaccess删除斜杠(/)之后的所有字符 [英] Rewritecond htaccess remove all characters after slash (/)
本文介绍了Rewritecond htaccess删除斜杠(/)之后的所有字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下htaccess
I have the following htaccess
Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteBase /
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
这是删除斜杠和URL末尾.如何不仅删除斜杠,而且删除斜杠后的所有字符?或发送404也许??哪一个更好 ?以及如何做到?
That is removing slashes and the end of my urls. How can remove not only the slashes but all characters after the slash ? Or send a 404 maybe ?? Which one is better ? and how can it be done ?
例如www.mysite/index.php/index.php或其他任何内容.
For example www.mysite/index.php/index.php or anything else.
推荐答案
如果仅尝试在斜杠后删除所有字符,则
If you just try to remove all characters after slash:
Options -Indexes +FollowSymLinks
ErrorDocument 404 /404.php
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+\.php)/.* $1 [R=301,L]
对于404错误,将最后一行更改为:
For 404 error change last line to:
RewriteRule ^[^/]+\.php/ - [R=404,L]
这篇关于Rewritecond htaccess删除斜杠(/)之后的所有字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文