pretty urls htaccess


Am trying to set up ‘pretty urls’ (or short urls) using htaccess and php. Have found several sites on the topic, but fail to have success - clearly I’m not understanding. Any direction would be much appreciated. My site is pretty simple. All pages are included at index.php, so urls look like:
My goal is for urls to display:

Index files contains this:

<?php $request = str_replace("", "", $_SERVER['REQUEST_URI']); $params = split("/", $request); ?>

HTACCESS file contains this:
#Options +FollowSymLinks
#RewriteEngine On

#RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteCond %{SCRIPT_FILENAME} !-f

#RewriteRule ^.*$ ./index.php


By “simple site”, did you mean only a few pages? If so, why rewrite the page names, just use them.

If you are trying to hide arguments, just use session variables instead.

But, if you still want to rewrite the names, I think this .htaccess condition will work:

RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?

Good luck…


it looks like your htaccess file is commented out so nothing will run # act as comment lines in htaccess

Here’s how I would do it:

[code]Options FollowSymLinks
Options SymLinksIfOwnerMatch
RewriteEngine On

RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,L][/code]

any url such as would match index.php?page=about you would have to change any links yourself in index.php as the old patten will still work so make sure you set them up like

In your index file you can get the page using a GET like:

[php]$page = $_GET[‘page’];[/php]


Sorry, me bad, cross-posted to someone else who asked a similar question…

Daveismyname, is correct. Do it that way for your project!


Whoo-hoo, that works! Thanks, daveismyname - you are now one of my favourite Dave’s!


haha glad to hear it :wink: