Howto redirect links or rewrite addresses …
Redirect everything to a “maintenance” message
RewriteEngine on RewriteRule !wartung.htm$ http://www.foo.tld/wartung.htm [R,L]
redirects everything but wartung.htm
RewriteCond /maintenance.html -f RewriteCond !maintenance.html RewriteRule ^.*$ /maintenance.html [L]
if maintenance.html exists, everything is redirected to this page.
Redirect everything on the same host to Port 443 (SSL)
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Simple redirect in .htaccess
Redirect / http://www.foo.tld/
or
Redirect 301 / http://www.foo.tld/
Redirect everything to a single URL (.htaccess)
RedirectMatch ^.*$ http://www.domain.tld Redirect / http://www.domain.tld
If PHP ist installed you can use as well:
<?php header("Location: http://psc.tobanet.de"); ?>
or to give a specific http_response_code other than 302:
<?php header("Location: http://psc.tobanet.de", true, 301); ?>
Put this in your index.php and your visitor will be redirected.
To force a https (ssl) connection for a directory with basic auth the following hack works if you have to workaround a loadbalancer doing the ssl connection:
Assumption:
RewriteEngine On SetEnvIf SOME_HEADER_SSL ^1$ let_me_in # redirect to https: ErrorDocument 403 /403.php RewriteCond %{HTTP:SOME_HEADER_SSL} ^0$ RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] order Deny,Allow Deny from all allow from env=let_me_in AuthName "Secure dir" AuthType Basic AuthUserFile /htpasswd AuthGroupFile /htgroup <Limit GET> require group allin </Limit>