-
Hey there,
Can anyone help me or point me in the right direction for masking a link? For example:
www.domainname.com/?id=1
www.domainname.com/bandname
How would I get "bandname" to take you to "?id=1"
I hope I can break this down so someone can help.
Thanks a bunch in advance!
-
I'm not 100% sure what you want... I have an idea, though.
Clarification & turtle dollars would help ;)
-
For example, do you already have some sort of Content-Management System, or just thinking about this stuff before you get started?
-
Google for 'Search Engine Friendly URL mod_rewrite'.
-
IMO, better than mod_rewrite redirecting the browser is a mod_rewrite *hidden* or *server-side* redirect.
Plus, I don't think the article Stylise mentions does exactly what you what (but I'm not quite sure what you want).
What *I* do is this:
All the links/urls are like:
www.ghscc.com/about/
www.ghscc.com/articles/firefox/1/
www.ghscc.com/newsletter/alerts/
But I'm using mod_rewrite to redirect any URL that does not have a period in it to page.php. BUT the user doesn't get redirected, i just tell APACHE that I really want page.php.
THEN, in page.php, we $_ENV[REQUEST_URI] (learn the $_ENV superglobal!), grab that string (/newsletter/alerts/), for example, and then, in our MySQL database, grab the page_id associated with that URL.
There are a few more details, but that's how we do it.
The benefit is the user & the search engine ALWAYS see /newsletter/alerts/, and the PHP can grab an ID, and if sometime in the future I lose my mind, drop PHP, and do ASP or something, the URL won't break because it used an old ID or because it referenced a PHP file that doesn't exist anymore.
Whew!
If you want the code I'm using in my rewrite file, ask for it... and the php code I can also share w/ you... but turtle dollars would help
-
Stylise meant the same thing. Apache's mod_rewrite is what you are looking for.
-
Code:
RewriteRule ^([^\.]*)$ /php/page.php
What I do!
PHP Code:
<?php
$curPage = strtok($_ENV[REQUEST_URI],'?'); //remove GET variables
if ( strpos($curPage,'.')===false and (substr($curPage, -1) != "/") )
{
$curPage .= "/"; //add final slash (internally) if not present
}
... database lookup ...
?>