Search code examples
phpopencart

Custom Url on opencart


now i'm doing some project with opencart platform. i want to know, do we able to custom the url?

as i know, if we want to put other information on url. the format will be like this

https://random.com/index.php?route=api/seller/order&seller_id=123

is there any posible to custom the url like this

https://random.com/index.php?route=api/seller/<seller_id>/order
 
example : https://random.com/index.php?route=api/seller/123/order

the seller_id will be dynamic and if it posible, how do i can get the seller_id from the controller?

please help


Solution

  • You can use Apache mod_rewrite to modify URL

    .htaccess

    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} route=api/seller/(\d+)/order
    RewriteRule ^index.php index.php?route=api/seller/order&order_id=%1 [L]
    

    http://random.com/index.php?route=api/seller/123/order
    will turn into
    http://random.com/index.php?route=api/seller/order&order_id=123