2

I have a URL like this : https://example.com/coins/1&order_by=today and several categories such as:

https://example.com/coins/1&order_by=new
https://example.com/coins/1&order_by=trending

You can also change the page so it will be 2 instead of 1 etc.. like : https://example.com/coins/2&order_by=today

I would like to change these to have https://example.com/today?page=1 etc instead of this above

I have read many responses on this subject and I searched the web, but unfortunately no solution works. I tried this but it does not works:

RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*&)?order_by=new(&.*)?$
RewriteRule ^(.*)$ $1?new/%1/%2 [L]
3
  • 1
    Please do add your tried htaccess rules file in your question, thank you. Commented Jul 4, 2021 at 10:47
  • RewriteEngine on RewriteBase / RewriteCond %{QUERY_STRING} ^(.*&)?order_by=new(&.*)?$ RewriteRule ^(.*)$ $1?new%1/%2 [L] Commented Jul 4, 2021 at 15:21
  • 1
    Pointless to try and match on the query string here - because your URLs don’t have any. Commented Jul 5, 2021 at 6:41

1 Answer 1

2

Try following htaccess Rules, please make sure to place these Rules at top of your htaccess file. Make sure to place your htaccess file inside root folder along with coins folder(not inside coins folder).

Please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteBase /
RewriteCond %{THE_REQUEST} \s/coins/(\d+)&order_by=(\S+)\s [NC]
RewriteRule ^  /%2?page=%1 [R=301,L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.