Rewritecond htaccess remove all characters after s

2019-09-19 23:39发布

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]

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 ?

For example www.mysite/index.php/index.php or anything else.

1条回答
冷血范
2楼-- · 2019-09-20 00:12

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]

For 404 error change last line to:

RewriteRule ^[^/]+\.php/ - [R=404,L]
查看更多
登录 后发表回答