PDA

View Full Version : mod_rewrite from port 80 to 443


gabrix
15th October 2006, 18:31
Never had problems with mod rewrite i suppose i'm using same rewrite rules i used in the passed apache2.conf .I don't want users forced to write https:// to reach tor website .Rewrite rules are in the virual host apache2.conf file bit :


NameVirtualHost 192.168.1.6:443

<VirtualHost 192.168.1.6:443>
ServerName tor.gabrix.ath.cx
ServerAlias tor.ath.cx
ServerAdmin gabrix@gabrix.ath.cx
DocumentRoot /var/www/fuck
ErrorLog /var/log/apache2/tor_error.log
TransferLog /var/log/apache2/tor_access.log
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/tor.crt
SSLCertificateKeyFile /etc/apache2/ssl/tor.key
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{tor.gabrix.ath.cx}/$1 [NC,R,L]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</VirtualHost>


I'm sort of trying commenting out alterantively the rules you see or adding others i find in the net with different details to make it work.i have also wrote it in the .htaccess file and made a rewrite.conf file 'included'.You can try yourself http://tor.gabrix.ath.cx & https://tor.gabrix.ath.cx.The HTTP url will answer with an another website i have on port 80 and calls for tor.gabrix.ath.cx don't get redirected on port 443 .I'm not into regex but is necessary to use that RewriteRule .* - [F] it's there for deleting isn't it?what's its right position?Is it necessary?
Thanks !

Megrain
15th October 2006, 19:44
Hi gabrix
add this line to your httpd.conf

LoadModule rewrite_module /usr/lib/apache2/mod_rewrite.so


Regards,
Megrain

gabrix
15th October 2006, 21:06
My fault .i have not mension apache version ( 2.0 ) and my OS (debian sarge 3.1 kernel 2.6),sorry !add this line to your httpd.conf LoadModule rewrite_module /usr/lib/apache2/mod_rewrite.soI'm not sure you know what you are saying an httpd.conf file for apache2 and a directive for apache used for apache2 ....

Megrain
16th October 2006, 07:40
Hi gabrix.
Ok.
I don't know Dabian that well.
but if your rewrite rules don't work check if the mod_rewrite.so module is loaded.
I used Suse 10 for my setup.
I also see that you are using Joomla,Mambo for the websites, that's why you need the rewriteengine on.Right?

Remove the rewrite commands from your vhost file and add it into the htaccess file in the directory of your website.
You can check if the rewrite module is loaded in joomla's System Info under the System tab in the backend.
This should be there.
Loaded Modules core prefork http_core mod_so mod_access mod_auth mod_auth_anon mod_auth_dbm mod_auth_digest mod_include mod_log_config mod_env mod_mime_magic mod_cern_meta mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_asis mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_imap mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy proxy_ftp proxy_http proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi sapi_apache2 mod_ssl

gabrix
16th October 2006, 14:06
I't's all right ,that's how we do in debian:
root@www:~# a2enmod rewrite
This module is already enabled!
apache2 enable module rewrite.
You are saying i better use the htaccess.txt in the joomla documents root dir.I'll give it a try!

gabrix
16th October 2006, 14:07
I't's all right ,that's the debian way:
root@www:~# a2enmod rewrite
This module is already enabled!

You are saying i better use the htaccess.txt in the joomla documents root dir.I'll give it a try!