Monday 9 July 2012

Apache redirect,alias and SSL

1. Redirect /files http://localhost/info.php
if you put the above in the htaccess and hit http://localhost/files. It will be redirected to http://localhost/info.php.

2. Error log in htaccess
php_value log_errors On
php_value error_log php_error_log.txt
The above two lines enable the log and write it to php_error_log.txt

3. Alias example: lets say you have the some files in downloads dir of c drive. But when you hit http://localhost/files, it has to fetch from c:/downloads. The below config achieves that
Alias /files "C:/downloads/"
<Directory "C:/downloads">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

4. If you want to force a particular url to be secure, try below config
<Directory "C:/Program Files/Apache Group/Apache2/htdocs">
SSLOptions +StrictRequire
SSLRequireSSL
SSLRequire %{HTTP_HOST} eq "www.drupalssl.com"
ErrorDocument 403 https://www.drupalssl.com
</Directory>

Note: After making changes restart apache and clear the browse cache. The redirect directive takes precedence over alias directive.
Reference:
http://www.apache-ssl.org/docs.html#SSLRequireSSL
http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html
http://httpd.apache.org/docs/2.0/mod/mod_alias.html
http://www.thewebhostinghero.com/tutorials/apache-alias.html

No comments:

Post a Comment