D
D
Doghdik2014-01-19 19:39:48
htaccess
Doghdik, 2014-01-19 19:39:48

.htaccess - extra slashes after the domain name. How to remove?

Hello! I had such a question because on my hosting, managed by the apache server, after the domain name, you can add an infinite number of slashes, and the site still opens.
Example:
http://имя_моего_домена//////имя_директории
I would like to remove all these slashes so that there is a redirect to a page without slashes, i.e.
http://имя_моего_домена/имя_директории
But the problem is that RewriteRule rules do not see many slashes right after the domain name and you can get rid of them only by using one redirect to the same page (R=301). In this regard, the question is - if it is impossible to check any special conditions for the content of the URI itself, then how else can you perform a redirect only once in the entire processing cycle, and when returning to the first rule for processing conditions after the redirect, simply skip the existing redirect every subsequent time?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex7r, 2014-07-18
@alex7r

Here is the answer:

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question