V
V
vladislav9972020-09-22 11:58:12
htaccess
vladislav997, 2020-09-22 11:58:12

How to route from /profile?id=1&url=test to /test?

Tell me how to make such a route through htaccess or something else:
Before: /profile?id=1&url=test
After: /test
Accordingly , test is a dynamic name that will change along with id

There is already this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-09-28
@shambler81

RewriteCond %{QUERY_STRING} (?:^|&)id\=1(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)url\=test(?:$|&)
RewriteRule ^profile$ /test? [L,R=301]

So if it's stupid for tz
RewriteCond %{QUERY_STRING} (?:^|&)id\=1(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)url\=(.+)(?:$|&)
RewriteRule ^profile$ /%1? [L,R=301]

And like this, if instead of test there is any value
The entry is a little excessive, but it is universal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question