Basic mod rewrite rule

Hello guys,

I am just learning htaccess and really struggling to put together my first rule.

I’m trying to rewrite the structure of my website.
I have individual .php files which I’d like to translate to a directory format.
For example: dog.php could be accessed by typing:

This is what I have so far:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^dog /dog.php [L]

Can anyone point out where I’ve gone wrong? Thanks very much in advance for any assistance.

ah think i’ve solved this with the help of this forum :slight_smile: thanks:

RewriteEngine on
RewriteRule ^/?([a-z]+)$ $1.php [L]


You’ve got it, by George!

As an aside, you only need the /? after the start anchor is you don’t know whether you’re using Apache 1.x or Apache 2.x. 1 requires the / and 2 refuses to match the / so the optional leading / is a good way to let both versions work.