V
V
Vladimir Mazepa2017-04-06 12:27:27
htaccess
Vladimir Mazepa, 2017-04-06 12:27:27

How to remove unnecessary from url using htaccess?

Hello, tell me how can I remove the extra from the URL
Now the url is this - site.com/?categoryID=1&sort=top
Need to slaughter "&sort=top" to make the URL site.com/?categoryID=27

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-04-06
@shambler81

site.com/?categoryID=1&sort=top
everything about the question is just part of the url dear. This is a get request.

RewriteCond %{QUERY_STRING} (^|&)categoryID\=([0-9]{1,})($|&)
RewriteCond %{QUERY_STRING} (^|&)sort\=top($|&)
RewriteRule (.*) $1\?categoryID%2

1 гет запрос и или с начала строки или в середине, 0-9 не менее 1 раза и цифру берем в переменную.
2. и если в урле есть сорт=топ - не забудь про экран равно
3. перенаправит все экран вопроса, иначе удалит весь гет запрос. далее подставляем название категория ид и номер из 1 конда соответственно только вместо бакса используется % вот только сам номер нужно протестить по идее это два.

Сергей Горячев, 2017-04-06
@webirus

webdomik.com/htaccess-rewrite-url-ubiraem-chast-urla

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question