-1

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.

Dions
  • 71
  • 4
  • 3
    Are you saying that you only want to serve `www.mysite.com/` and nothing else? Not even images, css, etc? – fejese Dec 23 '14 at 12:26
  • All I am saying is that I wanna cut all extra characters after the slash www.helo.com/index.php(/anything here)... So when a / is added to the url remove it. I ve got no folders on URL so every page is either solo something.php or something.php?something – Dions Dec 23 '14 at 14:00
  • When user add a slash+characters after the .php extension the site get all messed up no css no scripts. I wanna be able to refuse that either by sending a 404 or remove from the URL and revert the page to the base URL... – Dions Dec 23 '14 at 14:03
  • But is that true for all your files? Not just php but all others as well? Also you don't necessarily want to worry about users that wish to mess up their own browsing... If all your links are pointing to correct URLs, etc. you should not worry to fix crazy users :) You can provide a nice 404 page if you want but other than that ... – fejese Dec 23 '14 at 14:19
  • Thats what I am saying, How can I add a 404 to all extra after slash characters ??? – Dions Dec 23 '14 at 14:24

1 Answers1

0

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]
Croises
  • 18,570
  • 4
  • 30
  • 47
  • how if not only for .php but 404 for all extra characters after **/**, see my newly posted question in my profile –  Jul 21 '16 at 08:15