views:

248

answers:

1

Hi All,

I'm trying to implement a REST-style URL with a mod-rewrite turned on in .htaccess. There's a bit of a kicker which is that I'm developing in a test environment (new cpanel account). Here's the .htaccess:

RewriteEngine on

#REMOVE THIS LINE ON SITE LAUNCH!
RewriteBase /~myNewAccount/

#Hide .php extensions for cleaner URLS
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Options All -Indexes

The URL I CAN use looks like this:

www.example.com/~myNewAccount/index.php/id/50

I can access the PATH_INFO here, but when I try to do this:

www.example.com/~myNewAccount/index/id/50

...I get a 500 internal server error. I've tried implementing the solution found here by Gumbo but that mucks things up.

Ideas on what might be causing this?

+1  A: 

Try this rule:

RewriteRule ^index(/.*)?$ index.php$1 [L]

Or if you don’t want index to be in the URL path at all:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php/$0 [L]
Gumbo
Problem is i'll have LOTS of base urls (similar to index.php but with other names) and I'd prefer not to actually have a rule in there for every page. Is this possible?
jeerose
@jeerose: If you’re using relative paths in your substitution, then they will always depend on the base path.
Gumbo