问题
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:
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]
来源:https://stackoverflow.com/questions/27620311/rewritecond-htaccess-remove-all-characters-after-slash