Answer the question
In order to leave comments, you need to log in
Remove part of URL?
Hello!
You need to remove this part of the index.php?do=/ from the url .
The page is available at two addresses, for example:
/forum/thread/1068/
/index.php?do=/forum/thread/1068/
Or:
/blog/18/
/index.php?do=/blog/18/
PS defines duplicates... Tell me how to properly redirect to a url where there is no index.php?do=/ .
Thank you.
Tried like this
and like this:RewriteRule ^index.php?do=(.*)$ $1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?do=/$1
Answer the question
In order to leave comments, you need to log in
It doesn’t work for me to remove part of the url on Apache, I did it on php:
$request = $_SERVER['REQUEST_URI'];
if (stristr($request, 'index.php?do=/') !== false)
{
$url = str_replace('index.php?do=/', '', $request);
header('Location: ' . $url, true, 301);
exit;
}
RewriteCond %{QUERY_STRING} (^|&)do\=(.+)($|&)
#Если гет запрос содержит do= и более 1 знака, так же по краям (^|&)($|&) - это поскольку гет может быть вторым а следовательно начинаться с &
RewriteRule ^(.*) /%2 [L,R=301]
#то перенаправить на %2 - это аналог $2 только из конда ( вторая скобка из конда)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question