Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with question mark in url

Hi i am using multiple languages in my app and it is accessible by the url like www.asd.com/reg/?lang=es Is there some way with which i can remove this "?" from my url and it becomes like www.asd.com/reg/es and also my functionality of multiple language is working properly.

Thanks

like image 243
Inforian Avatar asked Nov 15 '25 16:11

Inforian


1 Answers

When you access url with ?lang=es, you will get a parameter named lang with value es in your view. This is generic HTTP url scheme.

With django, similar thing can be done using appropriate url pattern. For example:

url(r'^reg/(?P<lang>[\w]+)$', 'your_app.views.view_func',),

And in view

def view_func(request, lang=None):
    ...
    # lang will have value passed.
    # do your stuff

So when you access www.asd.com/reg/es, parameter lang will have value es in your view.

like image 165
Rohan Avatar answered Nov 18 '25 15:11

Rohan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!