views:

86

answers:

3

I have a development site on my machine at

localhost/~Jason/hfh/admin/?admin=collections

My .htaccess file is in the /hfh/admin/ directory. It says:

RewriteEngine On
RewriteBase /~Jason/hfh/
RewriteRule ^([A-Za-z0-9\-\_]*)$ index.php?admin=$1

But when I go to

localhost/~Jason/hfh/admin/collections

I get a "page not found" error. Can anyone tell me why?

(This is related to another question at this link.)

A: 

It looks like that would be sending you to the page /~Jason/hfh/index.php?admin=collections, when you want /~Jason/hfh/admin/index.php?admin=collections.

Try changing the rule to:

RewriteRule ^([A-Za-z0-9\-\_]*)$ admin/index.php?admin=$1
Jeffrey Aylesworth
The problem is that it's not redirecting ANYWHERE. The browser just tells me that /~Jason/hfh/admin/collections cannot be found. If it told me that /~Jason/hfh/index.php?admin=collections could not be found, that would be a different problem, if that makes sense.
Jason Rhodes
+1  A: 

If you have the .htaccess file in /hfh/admin/ make that the base to begin with.

RewriteBase /~Jason/hfh/admin/

then you may see what you expect. Also you'll may want a clause to not redirect when the File/Directory exists.

Does typing the expected result URL work?

/~Jason/hfh/admin/index.php?admin=Collections

Edit:

So what happens if you change the whole lot to:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /~Jason/hfh/admin/index.php?admin=$1 [L]
Simeon Pilgrim
Yes, the expected result URL works.
Jason Rhodes
using RewriteBase /~Jason/hfh/admin/ (and switching the rule back to not include "admin/") still gives me the same "page not found" error in the browser. It's not even trying to do the redirect at all.
Jason Rhodes
Simeon -- I changed to the RewriteCond lines you suggest -- no change. Same error, even when switching to a totally different browser to control for caching. SO FRUSTRATING
Jason Rhodes
It sounds like MOD_REWRITE is not running then.
Simeon Pilgrim
Repeated from above: Just tested the exact same .htaccess file and directory structure on my webhost server and it worked perfectly. Still not sure why localhost doesn't work, but that's definitely the problem.
Jason Rhodes
Ok, can you remove the .htaccess from the parent directory, then after that test, then change to single: RewriteRule .* /~Jason/hfh/admin/index.php?admin=collections [L] and check if that has an effect.
Simeon Pilgrim
A: 

The short, direct answer for now appears to be: you can't use mod_rewrite on your localhost.

Jason Rhodes