Fake Directory Name returns Value
Moderator: General Moderators
Fake Directory Name returns Value
If I send a user to a page (say http://www.tbmchicago.com/somekindauniquename) how can I make it so they get moved to http://www.tbmchicago.com/index.php and $username gets set to somekindauniquename?
The script will have to POST it to that page using http://www.php.net/curl your other page will have access to it in the standard $_POST superglobal array
mod_rewrite to a script that will assign a unique name for $username
IE
Either set a cookie or session variable and then redirect to index.php using header("Location: index.php"); You could also stick it in the url.
IE
Code: Select all
// if traffic's sparse this will do
$username = time();
// this will do if traffic's heavy
$username = sha1(uniqid(1));Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Oh, I read wrong.
mod rewrite something like this
Redirect_script.php
mod rewrite something like this
Code: Select all
RewriteEngine On
RewriteRule ^([a-z0-9]+)$ redirect_script.php?username=$1Code: Select all
session_start();
$_SESSION['username'] = $_GET['username'];
header("Location: index.php");Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Doing what ~scrotaye said will work, but you *can* change it a bit to not even worry about tacking on the $username. $_SERVER['REQUEST_URI'] won't be rewritten, so you can still get the requested dir from there:
.htaccess
redirect_script.php
This particular code is untested, but I use this theory on my website and it works beautifully.
.htaccess
Code: Select all
RewriteEngine On
RewriteRule ^.+$ redirect_script.phpCode: Select all
list(,$username) = explode('/',$_SERVER['REQUEST_URI']);Real programmers don't comment their code. If it was hard to write, it should be hard to understand.