0

I am trying to establish a rewritemap using a simple txt file for a special project that will ultimately contain about 150 redirects.

I've read through the other posts here and tried to apply alternate mods, but I just can't make a single redirect from this actually work as expected :-/

To confirm my setup:

I am using an include .conf to update my httpd.conf for the proper Virtual host. Upon running /scripts/rebuildhttpdconf (and 'service httpd restart') it is applied without error and the appropriate Include Path reference within httpd.conf becomes uncommented, which tells me it is finding the include file as expected. The Include file is called 'redirecttest2.conf' and contains:

RewriteMap redirect2 txt:/home/example/public_html/redirecttest/redirect2.txt

At the location referenced above, I have the file 'redirect2.txt', which for testing purposes contains:

maintenance.html    http://www.example.com/maintenance2.html
maintenance1.html   http://www.example.com/maintenance2.html

So my expectation would be that when entering 'example.com/maintenance.html' it would then be redirected to maintenance2.html, etc.

In the .htaccess file at the root of the effected domain, I currently have the following:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(\.(js|css|less|png|php|swf|flv|jpg))$
RewriteCond {redirect2:$1} !=""
RewriteRule ^/(.*) ${redirect2:$1} [R=301,L]

However, this does not currently have any effect. Entering example.com/maintenance.html or maintenance1.html does not perform any redirection - with or without the first two conditionals commented out.

I have tried numerous variations, and at times been able to break it altogether (rewrite loop error, whitescreen, or even cases in which the redirect works but instead of going to maintenance2.html, it appends /home/example/public_html to the url - ???) - but at no point can I get the example above to redirect as expected.

I tried getting assistance from the host of the VPS, but they do not provide support for such modifications.

I am hoping someone could look at the above and maybe see something glaring that I am missing? ANY thoughts appreciate...

Cœur
  • 37,241
  • 25
  • 195
  • 267
busy1
  • 23
  • 7

1 Answers1

0

I was finally able to resolve the issues with my RewriteMap.

In the .htaccess file at the root of the impacted domain, I am now using the following:

RewriteEngine On
RewriteCond %{REQUEST_URI} !(\.(js|css|less|png|php|swf|flv|jpg))$
RewriteCond ${redirect2:$1} >"" [NC]
RewriteRule ^(.*) ${redirect2:$1} [R=301,L]

This now appears to work - at least for basic url's.

Cœur
  • 37,241
  • 25
  • 195
  • 267
busy1
  • 23
  • 7