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?
Grabbing URL Variable
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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
or
to http://domain.com/index.php?page=somepage or http://domain.com/somepage.php depending on which you used.
Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z]+)$ /index.php?page=$1Code: Select all
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z]+)$ /$1.php