Gregg
May 20, 2011, 5:06am
1
Hello all,
I’m having a great difficulty understanding how to use the url rewrite capability of htaccess.. this is what I would like to do:
Convert the user typed url: www.something.com/about/
Into: www.something.com/index.php?p=about
With much thanks, could anybody tell me how I could do this?
Also, while we’re discussing htaccess, I am wondering if its possible to redirect any 404 error..or any error for that matter to the homepage with errors.. (www.something.com/index.php?p=errors )
Thanks guys, you’re great!
Sniper
May 21, 2011, 10:18pm
2
.htaccess rules can be tricky, thats why I prefer do it how wordpress does it.
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
then in your index.php
[PHP]<?php
echo ‘
’;
print_r($_SERVER);
echo ‘ ’;
$path = trim($_SERVER[‘REQUEST_URI’], ‘/’);
if ($path == ‘about’)
{
echo ‘about page’;
//or include(‘about.php’);
//or go into the database to get the page contents
}[/PHP]