Page 1 of 1

Grabbing URL Variable

Posted: Tue Dec 20, 2005 1:11 pm
by Zoram
I have been curious about how to grab a certain part of a URL to use as a variable..,

For example on a URL: http://www.someSite.com/1523636 how would you grab the 1523636 to use? and what page would it be the index.php file that would do the grabbing?

Posted: Tue Dec 20, 2005 1:30 pm
by John Cartwright
If you want it in that format then your going to have to use something like mod rewrite to transparantly write the query string. The query string is the ?mode=reply&t=42090 in the url. What mod rewrite will do is match a regex pattern of the url.. in your .htacess file you would have the following code to change http://domain.com/somepage

Code: Select all

RewriteEngine On
RewriteBase /

RewriteRule ^([A-Za-z]+)$  /index.php?page=$1
or

Code: Select all

RewriteEngine On
RewriteBase /

RewriteRule ^([A-Za-z]+)$ /$1.php
to http://domain.com/index.php?page=somepage or http://domain.com/somepage.php depending on which you used.

Posted: Tue Dec 20, 2005 3:34 pm
by Zoram
so... if i make a subdomain... profile.site.com/42521 then change the .htaccess in the folder to the rewrite then i can use that subdomain as kind of easy linking... that's what i was looking for, thanks!