• Resolved xeonz

    (@xeonz)


    After adding Access Orgin in htcaccess for 2nd domain this starts a redirect loop on that domain. I’m trying to figure out how to fix this. The original URL works and the new domain looks like working but it reloads infinity every second. The 2nd URL works normally when the LS plugin is Off/Complete Debugmode.

    # START ALLOW OTHER ORGINS
    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin https://MYURL.MYURL.se
    Header set Access-Control-Allow-Credentials true
    </IfModule>
    # END ALLOW OTHER ORGINS

    Any ideas?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter xeonz

    (@xeonz)

    Hi to myself!

    I think I found the issue, I was turned off Guest mode caching.

    Thread Starter xeonz

    (@xeonz)

    I was found the issue but still Guest mode caching is making a big improvement on site so it good if it’s possible to get this to work.

    Access to fetch at ‘https://mysite.io/wp-content/plugins/litespeed-cache/guest.vary.php&#8217; from origin ‘https://my.newsuburl.com&#8217; has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

    Adding this but then I get a redirect loop:

    # START ALLOW OTHER ORGINS
    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin https://my.newsuburl.com
    Header set Access-Control-Allow-Credentials true
    </IfModule>
    # END ALLOW OTHER ORGINS

    Any idea?

    Plugin Support qtwrk

    (@qtwrk)

    cache-control: max-age=3, must-revalidate

    try make it max-age=0,no-cache, must-revalidate

    Thread Starter xeonz

    (@xeonz)

    Hi,

    I was trying to add this:

    <IfModule mod_headers.c>
    SetEnvIf Origin ^(https?://(?:.+\.)?mysite\.com(?::\d{1,5})?)$   CORS_ALLOW_ORIGIN=$1
    Header append Access-Control-Allow-Origin  %{CORS_ALLOW_ORIGIN}e   env=CORS_ALLOW_ORIGIN
    Header merge  Vary "Origin"
    Header set Cache-Control "max-age=0, no-cache, must-revalidate"
    </IfModule>

    Still the same issue.

    Plugin Support qtwrk

    (@qtwrk)

    https://ek___.io/wp-content/plugins/litespeed-cache/guest.vary.php

    where did this URL comes from ?

    and the page URl is https://b____.3on.se/a/viktor-grahn/

    Thread Starter xeonz

    (@xeonz)

    Now I have deactivated Origin htcaccess fix so the layout is broken in subsite with error message in Chrome console.

    This is the <strong>main site (working)</strong>: https://ek____.io/a/viktor-grahn/

    And this is my subsite/ mirror site I added with Domain alias in eko___.io Webhosting + Domain mapping plugin in WP:

    https://hi.3on.se/a/viktor-grahn/ (I can remove URL after you seen this)

    Can I somehow get Guest Cache to work on subURL or how can I disable “Guest Cache” only on other Origin domains?

    • This reply was modified 3 years, 1 month ago by xeonz.
    • This reply was modified 3 years, 1 month ago by xeonz.
    • This reply was modified 3 years, 1 month ago by xeonz.
    Plugin Support qtwrk

    (@qtwrk)

    I see

    the issue is the guest.vary.php was coming from ek….io domain , so it (tries to) redirects it back to ek…..io , while the page retained on https://businesscards.3on.se and then end up in loop

    try add this code to your wp-config.php , at top of it

    
    if (strpos($_SERVER['HTTP_HOST'], "businesscards.3on.se") !== false){
      define( 'LSWCP_PLUGIN_URL', 'https://businesscards.3on.se/wp-content/plugins/litespeed-cache/' )
    }
    
    Thread Starter xeonz

    (@xeonz)

    Hi,

    Now I think I got it to work, one problem with looping redirect was also the mapping plugin I was installed before, I removed this and added below code + Origins code in htcaccess:

    $allowed_hosts = array('hi.3__.se', 'foo.newsubexample.com');
    if (strpos($_SERVER['HTTP_HOST']) || !in_array($_SERVER['HTTP_HOST'], $allowed_hosts)!== false) {
    	define('LSWCP_PLUGIN_URL', 'https://hi.3__.se/wp-content/plugins/litespeed-cache/');
    }

    Update: Now I have removed code in htcacess and it works with only the code in wp-config.

    Now all my original site works from hi.3__.se . Can I block so only the URL I choose works on the subsite? For example, if I want only hi.3__.se/abc* to work and the rest redirects to the original site home https:://eko___.io/ .

    • This reply was modified 3 years, 1 month ago by xeonz.
    • This reply was modified 3 years, 1 month ago by xeonz.
    Plugin Support qtwrk

    (@qtwrk)

    the thing here is that you need to fit the domain URL in that LSCWP_PLUGIN_URL when you access from different domain , so you need that define in wp-config to pre-define it before LSCWP itself defines it

    yes , you can use rewrite rule to redirect non-abc* to your site.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Reload Loop on 2nd domain name after added Allow-Origin’ is closed to new replies.