Friday, March 1, 2013
Apache Virtual Hosts and Url Rewriting
Today I setup our site in apache that uses javascript to make third party ajax calls to remote web services.
We had the javascript deployed to apache and the backend web services elsewhere.
I configure apache like so:
In order to rewrite all requests that don't match to the index page I added the rewrite rule.
In this case we would add server.example.com to our hosts file on our development box.
Put the following in your .htaccess file in your public_html directory: RewriteRule ^(.*)$ index.html [L]
Add this to httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/Users/bob/projects/someproject"
ServerName server.example.com
<Directory "/Users/bob/projects/someproject">
AllowOverride All
</Directory>
</VirtualHost>
Finally make sure you have this in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
http://httpd.apache.org/docs/2.2/mod/core.html
http://stackoverflow.com/questions/13737738/rewriterule-for-index-page-in-localhost
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment