Loading...
 
Skip to main content

Features / Usability


Customizing secure pages with mod_rewrite

I've wanted to have certain parts of the site be more secure, served over SSL, and thus did some experimenting with some mod_rewrite rules. I'd like to get some feedback on my work, which, in testing has worked for me.

Goal:

  • To have all the admin pages be SSL
  • All user preferences (esp when changing password) to be SSL
  • To be able to create pages with keyword names (this case secure) that automatically were redirected to SSL
  • Not to break the already working login ssl process
  • Redirect all but the above back to port 80


Please, comments and suggestions are encouraged.

Example:
(from provided .htaccess)

Copy to clipboard
RewriteEngine On RewriteBase /base RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} tiki-admin.*$ [OR] RewriteCond %{REQUEST_URI} tiki-login.*$ [OR] RewriteCond %{REQUEST_URI} tiki-user_preferences.*$ [OR] RewriteCond %{REQUEST_URI} secure.*$ [OR,NC] RewriteCond %{QUERY_STRING} .*secure.*$ [NC] RewriteRule ^.*$ https://mysite/base/$0 [L] RewriteCond %{SERVER_PORT} 443 RewriteCond %{REQUEST_URI} !tiki-admin.*$ RewriteCond %{REQUEST_URI} !tiki-login.*$ RewriteCond %{REQUEST_URI} !tiki-user_preferences.*$ RewriteCond %{REQUEST_URI} !secure.*$ [NC] RewriteCond %{QUERY_STRING} !.*secure.*$ [NC] RewriteRule ^.*$ http://mysite/base/$0 [L] ... rest of file

One thing I've noticed when running it through its paces, is that the categories drop down and wysiwyg editor do not work in SSL redirected pages when the return rules are active. Deactivating the return rules and they function normally. I assume it has something to do with the javascript. Its not a make or break for me, but certainly something I'd like to remedy.

Thoughts or directions to pursue?


Ok, what I've determined is that something about the return rules is causing some parts of the SSL pages not to load as SSL. This is not a problem when the return rules are not included. The goal then would be to get the return rules not to be parsed if the first block is matched, something similar to an "else".

I'm playing with means of resolving this.