PDA

View Full Version : .htaccess RewriteRule issues.


Majoracle
12-13-2006, 02:36 AM
.htaccess is my weak point, so forgive me if I sound like I have no idea. Basically I'm trying to create rewrite, but everything is in a directory, including the .htaccess file itself. My question is, how would I go about creating this?

Everything is in http://www.website.com/directory (I can't use real URLs because the area is protected), and I've tried the following:

RewriteEngine On
RewriteBase /

RewriteRule ^(.*) index.php?page=$1 [L]
^ That displays http://www.website.com/ under the URL http://www.website.com/directory
RewriteEngine On
RewriteBase /

RewriteRule ^directory/(.*) directory/index.php?page=$1 [L]
^ That just doesn't work
RewriteEngine On
RewriteBase directory/

RewriteRule ^(.*) index.php?page=$1 [L]
^ And neither does that.

Help? And as I've already said, .htaccess and the Rewrite stuff is a weak point of mine, so any other Rewrite tips are welcome too.

Thanks.

Majoracle
12-13-2006, 05:43 AM
Never mind, I figured it out. I forgot the first / on the RewriteBase, and few other things.
Working code:

RewriteEngine On
RewriteBase /directory/

RewriteRule ^([a-z]+)$ index.php?page=$1 [L]

But if anyone knows a better way of doing it, please, share.