Forum Moderators: coopster
i dont know the name of this, so i will go to the point:
i have
http://www.example.com/sometext
i want a way to get "sometext" in a variable in php, so every time a user type, the uri + "sometext" i can redirect that to a php scritp and use it.
i've seen this in lots of sites but in unable to find how to do it,
for example: <snip>
thanks!
sorry for my english, im learning :)
[edited by: eelixduppy at 10:24 pm (utc) on Mar. 24, 2008]
[edit reason] no URLs, please see charter [/edit]
You can use the $_GET superglobal array [us2.php.net] strings from the uri, however, the format will be slightly different--something more like the following:
http://www.example.com/?var=sometext
The format you have shown in your example, however, could still be used in the same method with GET, however, you are going to also have to incorporate some form of mod_rewrite [httpd.apache.org]. For more information or help regarding mod_rewrite, please refer to our Apache forum [webmasterworld.com] as that is the appropriate place for such questions.
this is not a php thing
what you need it to do the following:
create a file named .htaccess
add following content inside (without #s):
###############################
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9\-\_]+)$ index.php?param=$1 [L]
###############################
upload this file to root folder, where your index.php is
and have whaterer is after / from index.php as $_GET['param']
this RewriteRule only accepts a-z, A-Z, 0-9, - and _
use the rule ^(.*)$ to match any character after /
hope this helps