How to fix RewriteRule RewriteMap syntax

35 Views Asked by At

I am writing a multi-site platform and currently using the following in my virtualhost/.htaccess

RewriteMap sitemap "txt:/home/fb/multimapper/map.txt"
RewriteCond %{HTTP_HOST} (.*) [NC]
RewriteRule (.*) /home/user/public_html/multimapper/sites/${sitemap:%1}/$1 [L]

I want to put the trailing slash (/$1) within the rewrite rule so I can add a universal 404 page (before anyone asks: I don't want to use multiple ErrorDocument 404 entries - it's not feasible for this project).

So adding 404.php...

This: ${sitemap:%1}/$1 [L]

Becomes: ${sitemap:%1/|404.php?catch=}$1 [L]

EG.

RewriteMap sitemap "txt:/home/fb/multimapper/map.txt"
RewriteCond %{HTTP_HOST} (.*) [NC]
RewriteRule (.*) /home/user/public_html/multimapper/sites/${sitemap:%1/|404.php?catch=}$1 [L]

Problem is, ${sitemap:%1/ fails. Even if I backslash ${sitemap:%1\/

Does anyone have any ideas what I'm doing wrong?

Many thanks

0

There are 0 best solutions below