Z
Z
Zawchik2013-04-09 18:53:51
Apache HTTP Server
Zawchik, 2013-04-09 18:53:51

htaccess and closing slashes?

Greetings venerable habrasobshchestvo!
I turn to the universal mind to resolve the problem that has baffled me.
So, the task: through .htaccess, you need to glue pages with a slash ("/") and without it at the end of the address, while the main mirror will be pages without.
It would seem that everything is simple:
RewriteRule ^(.*)/$ $1 [L,QSA]
But for some reason QSA does not work, i.e. the final page does not receive anything in the POST ... What am I doing wrong?
If anything, here is the full text of all transformations:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ % {HTTP_HOST}/$1 [R=301,L, QSA]
RewriteCond %{REQUEST_URI} ^(.*)/$ [NC]
RewriteRule ^(.*)/$ $1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]
(first, make it the main mirror “without www”, secondly, remove the trailing slash, and finally transfer all non-existent files to /index.php)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
stan_jeremy, 2013-04-10
@stan_jeremy

yes, as said above, it's best not to rewrite everything that contains post requests
RewriteCond %{REQUEST_METHOD} !POST

M
MT, 2013-04-09
@MTonly

QSA stands for Query String Append and refers not to POST, but to GET data.
POST data is, of course, lost during an external redirect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question