Answer the question
In order to leave comments, you need to log in
How to remove first slash after URL?
Good time of the day.
I am using PHP routing.
htaccess:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?route=$1 [B,L,QSA]
And I can't get rid of double (triple, etc.) e.) slash right after the site address.
For example site.ru/article////page/5 in GET['route'] we get article////page/5 and the router will redirect to site.ru/article/page/5
But site.ru// //article/page/5 It won't redirect anywhere, since the GET['route'] parameter will contain article/page/5 and, accordingly, there will be no redirection.
No one will help with advice.
Answer the question
In order to leave comments, you need to log in
RewriteCond %{THE_REQUEST} //
RewriteRule ^(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?route=$1 [B,L,QSA]
If the user himself drives a URL with all sorts of garbage into the address bar, then he needs to wring his hands to give an error 404
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question