4

I have a domain for example

http://example.com 

and another domain

http://reallylargerdomain name.com 

I want if sombody access http://example.com/projects then server should proxy data from other url. For this i created following .htaccess file

Rewrite on RewriteRule ^projects/$ http://reallylargedomainname.com [P] 

this is not working but when i change it to following it works

Rewrite on RewriteRule ^projects/$ http://reallylargedomainname.com [R=301,L] 

any idea what's going wrong?

1 Answer 1

3

You need to make sure mod_proxy is loaded in your apache config. Without it, the P flag sends the proxy request but there's nothing that can handle the target. It's going to look something like this:

LoadModule proxy_module modules/mod_proxy.so 

The directory is obviously going to be tweaked to your paths if they are different.

Additionally, note that without the L flag in your rule, the proxy request won't be sent back into the processing pipeline until the rewrite engine is finished. So if you have other rules after the proxy rule, they will be applied before the proxy happens.

Sign up to request clarification or add additional context in comments.

1 Comment

Just a note, the P flag does imply the L flag. httpd.apache.org/docs/2.4/rewrite/flags.html#flag_p (this might have changes since answer was given)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.