I’m expanding the blog yet again to include a ‘Geek Development’ category. To be successful these days, you need to be a geek. Geeks rule the 21st century. Just see Bill Gates, the Google boys, Steve Jobs.. you get the picture.
This is also the first step of my roadmap for hottestgirlonline.com. See how this blog has really nice looking urls like http://www.brilliances.com/how-to-make-search-engine-friendly-urls-with-php instead of http://www.brilliances.com/p?1233. Well that’s what I wanted to achieve for the hottest girl online urls. Query strings are the easiest way to pass information with php but they make the url unreadable and give little hint to search engines about the page in question. So, it’s widely known that having well formed urls with targetted keywords is great for your serps… but how do you achieve this with php?
With any sort of coding, I’m sure there’s a few ways to do this, but this is what worked for me:
The magic lies in apache’s mod_rewrite handler. It has the ability to transform one url to another. ie. A nice url to the actual, uglier one that your php will understand. Here’s what I put in my .htacess file in the public_html root directory of hottestgirlonline.com:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^hotgirl/(.*)$ http://www.hottestgirlonline.com/hotgirl.php?name=$1
In this example, I’m redirecting everything with hotgirl/ to hotgirl.php?name=XX. For example, http://www.hottestgirlonline.com/hotgirl/Jessica-Alba will now actually point to http://www.hottestgirlonline.com/hotgirl.php?name=Jessica-Alba. So what happens is that visitors will see the nice url, but your webserver will use the ugly one for php processing purposes.
Now, because I’m making the url look like it’s under the hotgirl/ folder, this causes the php to think that it’s actually executing there. What I mean is that if you use the include() function to include addition php files (eg. the header, footer, and sidebar templates), you need to use the real DOCUMENT_ROOT. eg.
include($_SERVER['DOCUMENT_ROOT'] . '/header.php');
That’s it. How simple was that! The only thing left was to make sure to str_replace all the spaces in the girl’s names with a dash and swap over all the existing links to the new ones.
Hope google likes the length I’m going to just to make it easier for their spider to understand me! C’mon show me show love. :)
Popularity: 2%











0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment