PDA

View Full Version : .htaccess problems


sabret00the
01-22-2007, 11:49 AM
can anyone tell me why this isn't working? it's stored within the confessions directory.

RewriteEngine on
RewriteRule ^(.*)/$ index.php?confessionid=$1
RewriteRule ^(.*)/keyword/$ index.php?view=random&keyword=$1
RewriteRule ^(.*)/view=(.*)$ index.php?view=$1

with that i should be able to have these three working
www.site.com/confessions/580
www.site.com/confessions/view=random
www.site.com/confessions/view=votes
www.site.com/confessions/keyword/acid

and yet none of them seem to be working. if i add a backslash after each one i don't get a 404 but for some reason the php isn't picking up the $_GET's or something.

Adrian Schneider
01-22-2007, 01:57 PM
I know my webserver has problems picking up .htaccess files that aren't in the webroot (allowoverride setting or something)

Slighty off topic: do NOT use (.*) to match URLs! It is greedy, so it willl often match more than you wanted, and is lazy because it allows anything to go through when it shouldn't.

If it is an ID, use ([0-9]+)
If it is a title (clean), use ([-a-z0-9]+) (adjust according to needs)

RewriteEngine on
RewriteRule ^([0-9]+)/$ index.php?confessionid=$1
RewriteRule ^([-a-z0-9]+)/keyword/$ index.php?view=random&keyword=$1
RewriteRule ^(.*)/view=(.*)$ index.php?view=$1 #dont understand the logic here

sabret00the
01-24-2007, 12:54 PM
on the last one i wanted to be able able to have www.site.com/confessions/view=random/ and www.site.com/confessions/view=votes/ both work. thanks for your assistance thus far, i appreciate it.

i know that it's picking up the .htaccess file though, it's just not behaving as expected for some reason.