I'm wondering how sites like Pastebin and Twitter pass (what I assume to be) variables via the URL.
For example, take a Pastebin URL. It has the format of http://www.pastebin.com/<PASTE_UID>
. I'm wondering how they parse the UID without the server trying to treat it like an actual page. I can't imagine they generate individual files for each post.
I know this is most likely a combination of mod_rewrite and parsing the variable from the URL on the backend to extract the variable, but I'm at a loss on how to do it.
As you said, you can use apache mod_rewrite, i.e.:
Create an .htaccess
file on the root of your website with the following content:
RewriteEngine on
RewriteRule ^uid/(.*)$ /uid.php?uid=$1 [NC]
If, for example, the url is http://yoursite.com/uid/123456, apache will send the value 123456
via $_GET
request to uid.php
, you can get the uid value using:
<?php
if(!empty($_GET['uid'])){
$uid = $_GET['uid'];
//123456
}
?>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다