Answer the question
In order to leave comments, you need to log in
How to make a link without parameters?
Hello. I have been studying the web for a long time, but somehow my hands did not reach beautiful links. I don't know how to put it, now I'll try to describe what I mean.
There is a page domain.com/account/{And here is the user's unique UID}. It would be foolish to create a separate file for each user, you can do account#{UID}, you can account/?uid=123456. But still I want the link to be beautiful. I tried to dig in Google, unfortunately I didn’t find anything, I looked at a couple of web applications in which this is implemented, but I didn’t find anything either. (looked in the NGINX config, because I use this web server)
I would be very grateful for an explanation, or a link to an article for donuts like me. All the best :)
Answer the question
In order to leave comments, you need to log in
I would also like to know what is a beautiful address for you. If you need to substitute the account number, then you can do so.
domain.com/id1234
If you want not a number, but a login, then something like this.
domain.com/greck_chebureck
The logic behind such a request is both easy and hard.
First, you need to use the cnc module. It can be included in the .htaccess file. Secondly, you need to decide which global variables from the $_GET array are the main ones in your project.
I have, for example, a global variable from the $_GET['lang'] array is the main one and is mandatory sent to each page of the project.
Next, you need to decide where you have the user accounts folder.
Write the path to it in the htaccess file, something like this.
RewriteRule ^([a-z0-9-_.]+)$ /user-page/index.php?login=$1
RewriteRule ^([0-9]+)$ /user-page/index.php?id= $1
Well, in php to catch what variable came to the page. id or login.
If login, Then the user is called by login, if id, then by account number.
And remember, all accounts need to be stored in a database. And then I realized that for each user you want to create a separate php.
You don't need to do this.
digging in the wrong place,
this is called CNC
, I think this is already enough as the answer is googled in 1 second.
Now, according to redirects,
mod_rewrite does not consider GET to be part of the url, in principle, therefore it cannot get into the RewriteRule at any desire
. It is done like this
# 301 --- http://www.test3.com/faq.html?faq=13&layout=bob => bbq.html
RewriteCond %{QUERY_STRING} (?:^|&)faq\=13(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)layout\=bob(?:$|&)
RewriteRule ^faq\.html$ /bbq.html? [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question