D
D
Dmitry2015-10-27 14:40:42
Apache HTTP Server
Dmitry, 2015-10-27 14:40:42

CNC problem, address distortion, how to fix?

The bottom line is, there is a simple CNC rule, it looks like this:

RewriteEngine on
RewriteBase /

RewriteRule ^([\w\d]+)$ index.php?cpu=$1 [NC,L]

In this case, we get beautiful addresses of the form:
http://site/page
http://site/more_page

But if you add a question mark and some other nonsense to the address, it will also appear in the address bar, for example:
http://site/page?bla_bla_bla
At the same time, all this nonsense that comes after the question mark, although it appears in the query string, is impossible to get through $_REQUEST .
So the bottom line is, how to cut off this nonsense (everything that is added after the address, starting with a question mark) through the CNC rules, redirecting to the same page but without a line starting with a question mark? Well, or at least pass everything that comes after the question mark as a separate variable to the script ( index.php?cpu=$1&x=bla_bla_bla ), so that then using PHP to redirect to the correct address, without additions in the address bar?
That is, if there is a request like:
http://site/page?bla_bla_bla
It needs to be redirected through a 301 redirect to the page:
http://site/page
_

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Foo Bar, 2015-10-28
@atomheart

This nonsense is a GET request. If your site itself generates such requests, then you need to fix it in the site by converting them to CNC, and there will be no problem. And if you care about what users and robots can write, then let them write, it’s bad for you or something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question