.htaccess Redirect based on HTTP_REFERER

前端 未结 1 1817
灰色年华
灰色年华 2021-01-24 23:50

I\'m trying to do what I\'ve said above but I am getting a looping error and sometimes a 500 error!

What I want is for users requesting the root \'Home\' page of the sit

相关标签:
1条回答
  • 2021-01-25 00:24

    You're probably getting the 500 error because the [N] isn't a valid RewriteCond flag, are you thinking of [NC] (no case)?

    Additionally, you have a condition that directly contradicts the rule's match:

    RewriteCond %{REQUEST_URI} /index.php
    

    Says the URI must have a /index.php in it. While the rule itself:

    RewriteRule ^$ /Welcome [L]
    

    Says the URI must match ^$ which means it must be exactly /. And / will never be /index.php, so the rule is instantly invalid. Maybe you're thinking of either/or?

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^mydomain\.co\.uk$ [NC]
    RewriteRule ^(index\.php)?$ /Welcome [L]
    

    This will match the referer without case against mydomain.co.uk, and rewrite either / or /index.php to /Welcome

    0 讨论(0)
提交回复
热议问题