/    Sign up×
Community /Pin to ProfileBookmark

.htaccess and GET

When I use this in my .htaccess file:

[CODE]Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ index.php?user=$1 [nc][/CODE]

and I echo out user like this:

[code=php]echo $_GET[‘user’];[/code]

The following result is placed on the page:
[B]index.php[/B]

here is dir structure:

[code]
+root
|
+– album
| |
| +– .htaccess
| |
| +– index.php
|
+– index.php.
[/code]

I am trying to access the index.php page inside the [B]album[/B] dir

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 21.2007 — 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.
Copy linkTweet thisAlerts:
@The_Little_GuyauthorOct 21.2007 — 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.
Copy linkTweet thisAlerts:
@Jeff_MottOct 23.2007 — Try this instead.

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

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...