Mobile app version of vmapp.org
Login or Join
Vandalay111

: Methods to provide user data to web application in URL? I am aware that one method to provide user data to web application is to use query strings. For example http://www.example.com/get-page.php?home=aaa.html

@Vandalay111

Posted in: #Security #WebDevelopment

I am aware that one method to provide user data to web application is to use query strings. For example www.example.com/get-page.php?home=aaa.html would set variable home value to aaa.html and this is used in script get-page.php. Obviously, one could write anything instead of aaa.html and it is up to web application developer to check the input. According to this thread some web servers read the filename part of the URL and direct the request to some internal function. However, both methods use query strings. Are there any other methods besides query strings which allow user to provide random data to web application in URL?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Vandalay111

1 Comments

Sorted by latest first Latest Oldest Best

 

@Annie201

If your server is apache with mod_rewrite installed, then you can use friendly urls that map to real urls with the query strings then users only see the friendly urls.

Here's some code to put in .htaccess:

RewriteEngine On
RewriteRule ^section/(.*)$ /path/to/specialpage.php?section= [L]


Basically what these lines do is allow one to put in a friendly URL in the format of example.com/section/whatever where whatever is any text. When executed, the URL actually being processed is /path/to/specialpage.php?section=whatever because of the which means take the value located at the position of (.*).

To understand the detailed meaning of .*, you may want to look up regex (regular expressions).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme