Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to redirect URLs of the form subpage.php?sid=123 to named pages.

subpagemap.txt exists in the root and contains just the following delimited by Unix line endings \n:

1 a
2 b
3 c

The .htaccess is as follows:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteMap subpagemap txt:subpagemap.txt
RewriteCond %{THE_REQUEST} subpage\.php\?sid=([0-9]*)
RewriteRule ^.*$ ${subpagemap:%1|home}? [R=301,L,NC]

The problem is that I'm getting a 500 Internal Server Error.

When I comment out line 4 of the .htaccess, line 5 works fine and I get redirected to the default map - /home, which suggests it's the map file that's the problem.

As soon as I put the RewriteMap line back in, I get a 500 Internal Server error. I don't have access to the server logs and RewriteLog doesn't seem to work at all.

I have also tried the following substitutions one by one and together to try to isolate the problem:

RewriteMap subpagemap txt:/subpagemap.txt
RewriteCond %{THE_REQUEST} subpage\.php\?sid=([0-9]*)
RewriteRule ^.*$ /${subpagemap:1|home} [R=301,L,NC]

Any ideas what could be the problem?

share|improve this question
    
Next questions to ask: is subpagemap.txt in the location that RewriteMap expects to find it? Have you used an absolutely pathname. Next, can you view the Apache error_log to determine why the 500 Internal Server Error was generated? –  PP. Nov 27 '09 at 13:10
add comment

2 Answers

Actually, even if the servers supports it, the problem is that you are trying do define the RewriteMap in a per-directory context (e.g. in .htaccess file), which is not allowed: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteMap

Move the definition to server or virtual host configuration, and it should work.

I still realize you probably have figured it out in a year and a half :)

share|improve this answer
add comment

I found that the answer was that the server host doesn't support RewriteMap.

That wasted a good 5 hours or so of debug.

share|improve this answer
    
RewriteLog and RewriteLogLevel are your friends ;) –  Aleksandar Ivanisevic Nov 27 '09 at 14:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.