views:

290

answers:

1

The application i'm developing uses a certain file directory structure. Via the use of mod_rewrite and .htaccess files, i manage to have friendly urls for our users. It works fine on my local server, but once on the production server, it fails: apparently, the server throws a 404 error before the .htaccess has a chance to kick in.

Here is the .htaccess i'm working on (referenced as (1) here below):

IndexIgnore *
#Options +FollowSymLinks
RewriteEngine on

RewriteOptions inherit

RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*)$ /~extranet/extranet/$1 [NC,L,QSA]

On the server, it returns 404:

The server can not find the requested page:

<IP-ADDRESS>/~extranet/extranet/dev/foo/

(port 80)

In fact, it seems any redirect fails, although phpinfo() lists mod_rewrite among the loaded modules.

The server is brand new. (In case it helps, the 404 page lists Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.8 Server )

Where should i look for the mistake/misconfiguration?

UPDATE: more information

here is the file/folder structure and each .htaccess used:

<IP-ADDRESS>/~extranet/.htaccess (1)
<IP-ADDRESS>/~extranet/extranet/
                              L .htaccess (2)
                              L/dev/
                                   L .htaccess (3)
                                   L index.php
                              L/stable/
                                   L .htaccess (3)
                                   L index.php

(1) redirects all requests to folder "extranet" (2) redirects all requests not containing "/dev/" to folder "stable" (3) rewrites /extranet/foo/bar/ to index.php?app=foo&do=bar

+1  A: 

There's a tilde in here: <IP-ADDRESS>/~extranet/extranet/dev/foo/

Your regexes as specified will not match the tilde.

Perhaps you need to specify your RewriteBase properly for your remote webserver?

Amber
ok i'll try using the part with the tilde.Can you elaborate on how i should modify the RewriteBase ? I don't really understand that directive. Thank you!!
pixeline
Well the main questions are, a) where is your .htaccess that's doing the redirecting, relative to the webroot, and b) where is your target index.php file?
Amber
hi Dav, i've updated the question with the required information. Thanks for holding on !
pixeline
The 404 error you mention in your answer - what URL are you typing in your address bar when you get that?
Amber
here is the 404 url: http://<IP-ADDRESS>/extranet/foo/bar/
pixeline
Your .htaccess is inside /~extranet/, so it's never even finding the .htaccess to try to redirect - you'd want to go to http://<IP-ADDRESS/~extranet/foo/bar instead.
Amber