Click to See Complete Forum and Search --> : .htaccess and GET


The Little Guy
10-21-2007, 06:43 PM
When I use this in my .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ index.php?user=$1 [nc]


and I echo out user like this:
echo $_GET['user'];

The following result is placed on the page:
index.php

here is dir structure:

+root
|
+-- album
| |
| +-- .htaccess
| |
| +-- index.php
|
+-- index.php.


I am trying to access the index.php page inside the album dir

scragar
10-21-2007, 06:47 PM
the rewrite rule is a regular expression, surely you can set it to work on anything other than album.

^(^album)$

ofcourse this won't pick up the sub files/folders, but you can set it to something like:

^(^album(/.+)?)$

to allow sub folders(can't remember if forwardslash has a weird effect.

The Little Guy
10-21-2007, 06:55 PM
I can not get those to work. It doesn't display the page, I just get a 404.

mine displays the page, but not the GET


I am not searching any folders, I am just searching a database which holds all the files that are in the album.

The Little Guy
10-22-2007, 06:27 PM
Anyone?

Jeff Mott
10-22-2007, 08:48 PM
Try this instead.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} !index\.php$
RewriteRule (.*) index.php?user=$0