Htaccess question

design

#1

Hi,

I’ve got a little php backend I’ve written that takes an argument in the URL, like this:

http://www.domain.com/?page=about

I would like to have “friendly” URLs and I’m thinking that I want to do this via a .htaccess file. I guess that friendly URLs would be something like this:

http://www.domain.com/
http://www.domain.com/about

I’ve created the .htaccess file and added the following:

RewriteEngine On
RewriteRule /(.*) /index.php?page=$1 [PT,L]

Yet, when I try to go to http://www.domain.com/about, I get an error: “The requested URL /about was not found on this server.”

Obviously, the .htaccess file is not catching and modifying the URL like I’m expecting it to. Any advice?

Thanks,
Mike


#2

In per-directory configuration files (read: .htaccess) leave off the directory prefix in the pattern.

Example:

Given your document root is ~/example.com

And your .htaccess path is thus ~/example.com/.htaccess

then your directory prefix is /

and thus your pattern would be ^about$

for URL http://example.com/about

Second example:

Given your document root is ~/example.com

But your .htaccess path is ~/example.com/blog/.htaccess

then your directory prefix is /blog/

and your pattern would still be ^about$

for URL http://example.com/blog/about

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#3

Thanks Atropos7 - that worked exactly as I was wanting.