Need help with setting up the rewrite map

Renegade

Well-known member
Redirects are something I can't get my head around so naturally I am doing something wrong.

I need to setup a redirect map and have done the following 3 things but still can't get it to work. What could I be doing wrong?

Declare in httpd.conf
Code:
RewriteMap url_rewrite_map txt:/home/xyz/public_html/xf1.txt

Placed a file with the following text in xf1.txt
Code:
/forum-abc/lets-play-10131.html /community/threads/lets-play.70898/

Placed the following in .htaccess
Code:
RewriteCond ${url_rewrite_map:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*) http://www.site.com/${url_rewrite_map:$1} [R=301]
 
Yeah I got this working finally after some trial-error and redirect manuals. The key here is to get the rewrite rule correct. Rest is easy.

No there is no noticeable impact on the performance. If at all it might have added a quarter of a second to the loading time.
 
Yeah I got this working finally after some trial-error and redirect manuals. The key here is to get the rewrite rule correct. Rest is easy.

No there is no noticeable impact on the performance. If at all it might have added a quarter of a second to the loading time.
Okay, so is this correct? -

Code:
RewriteCond ${url_rewrite_map:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.*) http://www.site.com/${url_rewrite_map:$1} [R=301]
 
That is supposed to work according to the tutorials on the net but it did not. I had to modify it a bit to work. Basically I made the matching string more specific by adding the .html part in the end. And I put the entire URL in the rewrite map file so I removed the www.site.com part from the rewrite. The entire URL now comes from the map itself.
Code:
RewriteCond ${ErrorMap:$1|Unknown} !Unknown
rewriterule ^(.*\.(html)) ${ErrorMap:$1|404} [R=301]
 
Top Bottom