Redirect Problem (Triggering 404)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Trahb
Forum Commoner
Posts: 36
Joined: Sat Jan 30, 2010 9:09 pm

Redirect Problem (Triggering 404)

Post by Trahb »

I'm brain-dead right now. I've been staring at my computer for an hour+, and just can't seem to figure out what's going wrong.
I need an extremely light framework to house a personal project I'm working on, and decided making the simplest possible myself would be the best option.
So, as I've been told in numerous tutorials, I need to redirect ever page request to my index.php file. That makes perfect sense. What doesn't make sense is why the .htaccess content I've seen a myriad of times across the Internet won't work for me.

Here's what I've got in my .htaccess file

Code: Select all

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?c=$1 [QSA]
Three things to note:
1.) localhost/asdf takes me to localhost/index.php?c=asdf (it's doing exactly what I want here)
2.) localhost/asdf/ghjk results in a 404 error
3.) [QSA, L] at the end of index.php?c=$1 results in a 500 error

If anyone has any sort of explanation as to what I've done wrong, or suggestions on what to try, they'd be much appreciated.

Thanks for your time
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Redirect Problem (Triggering 404)

Post by Celauran »

Here's my .htaccess

Code: Select all

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
	Order Deny,Allow
	Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
Trahb
Forum Commoner
Posts: 36
Joined: Sat Jan 30, 2010 9:09 pm

Re: Redirect Problem (Triggering 404)

Post by Trahb »

Thanks for that faaast reply, but even using parts of that I get Error 404 when I try localhost/asdf/jkl
Post Reply