E
E
ertaquo2012-07-14 16:19:09
Apache HTTP Server
ertaquo, 2012-07-14 16:19:09

Apache removes slashes

I keep a small QR encoder at http://qr.nizarium.com/ . In theory, it should encode everything that is in the query string :
http://qr.nizarium.com/what-you-want-to-encode / => http://qr.nizarium.com/http%3A%2F%2Fhabrahabr.ru%2F => http:/habrahabr.ru/ This turns the site address into a non-working one after recognition. Blame it on Apache. It removes "extra" slashes even if they are encoded in urlencode. The found way to process the query string also does not work:

RewriteCond %{THE_REQUEST} ^[a-zA-Z]+\ ([^\ ]+)\ HTTP/
RewriteRule .* index.php?q=%1 [L]
I don't want to translate under /?q=…. How can I get back the missing slashes?
Apache/1.3.34

UPD: Changed everything to QUERY_STRING, but the problem is still relevant.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
phasma, 2012-07-14
@phasma

> I don't want to translate under /?q=…. How can I get back the missing slashes?
write a rewrite.

P
pel, 2012-07-14
@pel

RewriteCond %{THE_REQUEST} ^[a-zA-Z]+\ ([^\ ]+)\ HTTP/
RewriteRule .* index.php?q=%1 [L]

Tell me, why do you need RewriteCond here, if you just need to pass everything in the query string to the q variable? And what are these spaces (underlined: "… Z]+ \ ( [^ \ ] + ...")? Perhaps the parser has chewed it up.
Try leaving this regular expression:
RewriteRule ^(.*)$ index.php?q=$1 [QSA, L]

Or, if you look at your comment to the previous answer, then there is not enough:
RewriteEngine on
RewriteBase / 
RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]

P
pel, 2012-07-16
@pel

> RewriteCond %{REQUEST_URI} !^/$? it is necessary so that there is no cyclic redirection
. Without this, it works fine for me, it does not cycle. After the first redirect, the browser accesses an already existing file and, accordingly, the rule RewriteCond %{REQUEST_FILENAME} !-fwill no longer work.
I have Apache 2.0. Perhaps, indeed, in the first and it works differently. Unfortunately, there is no place to check it yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question