Closed Bug 1197501 Opened 10 years ago Closed 10 years ago

mod_rewrite not working correctly on http://l10n.mozilla-community.org

Categories

(mozilla.org Graveyard :: Localization Server, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: flod, Assigned: reed)

References

Details

It's probably just me being less smart than usual, but I can't get the mod_rewrite on our community server to work as expected. I have an app that works correctly locally on both Apache 2.2 and 2.4, and fails miserably on the server. I tried to create a minimal example https://l10n.mozilla-community.org/~flod/test_rewrite/ There's a text file in text/test.txt, opening https://l10n.mozilla-community.org/~flod/test_rewrite/aaa Should load the text file, but I only get a 404. Locally it works as expected. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule aaa text/test.txt [L] </IfModule> After spending hours trying to figure out the issue, I'm open for ideas.
Edited the example. Folder has only one text file in it https://l10n.mozilla-community.org/~flod/test_rewrite/sample.txt .htaccess file <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^test$ sample.txt [L] RewriteRule ^moz$ https://mozilla.org [L] </IfModule> https://l10n.mozilla-community.org/~flod/test_rewrite/moz Correctly redirects to mozilla.org, which means the .htaccess file is read and mod_rewrite enabled https://l10n.mozilla-community.org/~flod/test_rewrite/test Doesn't work, while locally loads sample.txt @Reed Do you have any clue why it fails like this?
Flags: needinfo?(reed)
Summary: mod_rewrite not working correctly → mod_rewrite not working correctly on http://l10n.mozilla-community.org
If the idea is to have a front controller, this is what I have in the stores_l10n app on the community server (and it took me a long time to find it): For the stores_l10n app I struggled with it and this worked: # Rewrite all requests to the front controller <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /~pascalc/stores_l10n/ # Existing files and folders are not redirected RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php [L,QSA] </IfModule>
Ugh, it's the RewriteBase. If I add this line it works RewriteBase /~flod/test_rewrite It also makes the projects absolutely a nightmare in terms of portability. But thanks, that's a first step in the right direction. I even tried playing with RewriteBase, but the URL reported as "not found" was absolutely correct, so I didn't try really hard. P.S. I don't think you need QSA in that .htaccess?
(In reply to Francesco Lodolo [:flod] from comment #3) > P.S. I don't think you need QSA in that .htaccess? It doesn't hurt to have it and it's not uncommon to set up redirects in which you don't want to loose the query string.
I think I finally found a solution, with a decent explanation here http://stackoverflow.com/questions/16762119/what-does-1-mean-in-an-htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$ RewriteRule ^(.*)$ - [E=BASE:%1] RewriteRule ^test$ %{ENV:BASE}sample.txt [L] </IfModule>
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: needinfo?(reed)
Resolution: --- → INVALID
Product: mozilla.org → mozilla.org graveyard
You need to log in before you can comment on or make changes to this bug.