1

I have a case like this :

  • http://example.com/
  • http://example.com/test/
  • http://example.com/auth/
  • http://example.com/auth/login
  • http://example.com/auth/forget_password

I need to change example.com into my IP (1.1.10.7) when user accessing path that containing auth.

The results I need are:

  • http://example.com/ => http://example.com/
  • http://example.com/test/ => http://example.com/test/
  • http://example.com/auth/ => http://1.1.10.7/auth/
  • http://example.com/auth/login => http://1.1.10.7/auth/login
  • http://example.com/auth/forget_password => http://1.1.10.7/auth/forget_password

I tried several times from reading on another StackOverflow question, but still not resolved.

Can anyone help?

3
  • You can try something like - RedirectMatch 301 ^/auth/(.*) http://1.1.10.7/auth/$1 Commented May 10, 2017 at 8:04
  • @Kunal: That will cause a redirect loop Commented May 10, 2017 at 8:11
  • 1
    @anubhava Oh yeahh I missed that part thanks Commented May 10, 2017 at 8:30

1 Answer 1

2

You can use this rule in your site root .htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} !=1.1.10.7
RewriteRule ^auth/ http://1.1.10.7%{REQUEST_URI} [L,NC,NE,R=301]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.