• I’m attempting to set up a rewriterule in my .htaccess file that will allow me to send visitors arriving via specific referrer to a certain wordpress page. I have been successful in setting up a rewritecond to accomplish this when forwarding the traffic to a non-wordpress file (ie. index.html), but when I attempt to rewrite the url to a wordpress url (ie. /welcome/) it’s creating an infinite loop for some reason — can anyone spot the error?

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_REFERER} wordpress\.org [NC]
    RewriteCond %{REQUEST_URI} !^/welcome/$
    RewriteRule .* /welcome/ [L,R]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kallywag

    (@kallywag)

    My thinking here is that the HTTP_REFERER condition should rewrite any requests coming from www.ads-software.com to mydomain.com/welcome/ which would then trigger the wordpress conditions and rewrite it to mydomain.com/index.php, which would then figure out via php how to display the /welcome/ page. Somehow it’s getting stuck in a loop though. Here is a slight modification that actually works to forward www.ads-software.com traffic to a non-wordpress file (indexold.html):

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_REFERER} wordpress\.org [NC]
    RewriteCond %{REQUEST_URI} !^/indexold.html$
    RewriteRule .* /indexold.html [L,R]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Thread Starter kallywag

    (@kallywag)

    Any mod_rewrite gurus out there that could take a stab at this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘rewriterule infinite loop’ is closed to new replies.