Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


HTACCESS - Page redirection
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

HTACCESS - Page redirection

kkrajkkkrajk Member
edited August 2016 in Help

I am using the current version of wordpress.
The below is what I am trying to achieve.

Scenario 1

  1. User types example.com/x in the addressbar

  2. User gets content from example.com/x

Scenario 2

1.User goes to site...

  1. Clicks on the link in the menu linking example.com/x

  2. User gets content from page example.com/y while at the sametime the addressbar shows example.com/x

If someone could guide me or give me the solution to achieve this through .htaccess, it would be a great help.

Thanks

Comments

  • ez2uk said: Clicks on the link in the menu linking example.com/x

    User gets content from page example.com/y while at the sametime the addressbar shows example.com/x

    That can be easily done with domain masking I Assume.

    Thanked by 1kkrajk
  • kkrajkkkrajk Member
    edited August 2016

    But wouldn't that by default show the alternate content always. What I would like to achieve is that the alternate content is only displayed while going through the menu (or links within the site) and not while accessing directly through the url

    or in reverse (i.e the alternate content is displayed only while accessing the page through typing the address in the addressbar or through an external link)

  • you probably want to take a look into the use of

    RewriteCond %{HTTP_REFERER}

    to be able to decide if someone has been send from another page or typed that url. as referers are optional behaviour there is no guarantee that this will always work, so don't use it in a way where displaying the content at all relies on that function.

    but I think your use case is very rare. why would someone type a complicated url manually and how should he even obtained these url while he normally isn't able to see it through the normal masked interface in first place?

    Thanked by 1kkrajk
  • Falzo said: why would someone type a complicated url manually and how should he even obtained these url while he normally isn't able to see it through the normal masked interface in first place?

    The typing in the addressbar is just a case. It could be anything apart from clicking on the actual menu link

  • Look into hotlink protection, sounds like the same thing as what you want to achieve.

    Thanked by 1kkrajk
  • @ez2uk said:

    The typing in the addressbar is just a case. It could be anything apart from clicking on the actual menu link

    ok, so only if the referer matches your own domain links should work as expected, otherwise you would want the user to be redirected to the main-site...

    Thanked by 1kkrajk
  • agentmishraagentmishra Member, Host Rep

    best is to look into the wp-mu tutorial, on website redirection using htaccess

    Thanked by 1kkrajk
  • Falzo said: ok, so only if the referer matches your own domain links should work as expected, otherwise you would want the user to be redirected to the main-site...

    To be precise...

    Referrer matches my site domain.com i.e user clicks on the link to the page from within the site

    domain.com/test (url in addressbar) = domain.com/subfolder/test (page content)

    If Referrer does not match my site domain.com i.e user comes to page from external url or by typing the url in the addressbar

    domain.com/test (url in addressbar) = domain.com/test (page content)

    There is also an additional requirement that when inside domain.com/test when the user has come from an external link or by manually tying url in addressbar, clicking on link to domain/test should display content from domain/test. There are 6 such links/routes that need to function this way

  • then you might want to use something like this:

    https://httpd.apache.org/docs/2.4/rewrite/access.html#referer-deflector

    to define your 6 links, based on your own domain as referer ;-)

    Thanked by 1kkrajk
  • Thanks. Will look into it.

Sign In or Register to comment.