1

I am trying to implement a simple rewrite, but looks like i am doing something wrong. What I am trying to do is that I have a url blog.example.com/articles/ which gives me 404 , and other urls are blog.example.com/articles/abc, blog.example.com/articles/xyz etc , which works fine, so I want blog.example.com/articles/ to show me home page which is blog.example.com instead of 404, but i don't want any other url ,which has something like /articles/* to be affected by that rule.

This is what I have tried so far

RewriteRule ^/articles$ /index.php [R=302]

which does not work

I have tried the redirection as well

Redirect "/articles" "http://blog.example.com/"

I works but it changes the url in the browser and also affects all other urls starting with /articles

Any help is appreciated

1

You can also use proxypass, for that enable mod_proxy in apache.

a2enmod proxy
a2enmod proxy_http

then allow your server to use apache as proxy

ProxyRequests On
ProxyVia On
<Proxy *>
      Order deny,allow
      Allow from xx.xx.xx.xx
</Proxy>

Now you can write rewrite rule as follows

RewriteEngine On
RewriteRule /articles$ http://blog.example.com [P,L]

Now when url matching blog.example.com/articles will come , it will fetch the result from blog.example.com without changing the url in the browser. It will only send the url blog.example.com/articles through tother urhe proxy, urls are affected.

  • yes that works. – Sunny Mar 4 '16 at 12:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.