Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force https for page when http entered

Status
Not open for further replies.
Place this in the /admin folder and set the file permissions to 755.
Code:
#!/usr/bin/perl

print "location:[URL unfurl="true"]https://www.domain.com/admin\n\n";[/URL]

M. Brooks
X Concepts LLC
 
Is this a separate file that executes when the directory is entered? That print statement must be there?

thanks
 
Basically it is a simple perl redirect.

All you need to do is replace the domain.com with your domain name.

Have a good Weekend!

M. Brooks
X Concepts LLC
 
I'm sorry to seem so stupid but is that a separate file in the admin directory that runs. If you just place a file in the directory, how does it get executed?

Thanks
 
sick 'm csross and make him tell you what the name of the file should be. :)
 
csross,

Just to point it out, if you have and with different DocumentRoots, AND you have PHP installed you can drop this into the DocumentRoot for (as index.php)and not have to change permissions

<?php
header("Location: ['SERVER_NAME']);
?>

Of course that assumes that you have PHP set up and that Apache parses .php, but it accomplishes the same as the Perl script.


Wishdiak
 
Name the file index.pl and place this file in your /admin directory.

On the command line change the permissions of the file to 755.

Then in your httpd.conf add index.pl like shown below.

#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.htm index.html index.pl
</IfModule>

Restart Apache and you are done.


M. Brooks
X Concepts LLC
 
There is another very easy way also. If you are using standard html, you could just use a META refresh statement in the header of your html page.

Here is how:

In the default html page in the directory, put this code right after the very first <html> tag:

<META HTTP-EQUIV=Refresh CONTENT="1; URL=https://www.domain.com/admin">

This will redirect to the page you want in 1 second. You can change the delay and/or show anything on page if you want. If you want it invisible, I would leave it at 1 or maybe even 0. That would be the easiest way to me.


-DJ
 
Why not use mod_rewrite. This is how I do it on my site:

RewriteEngine on
RewriteRule ^/(*.)register\.jsp
This tells Apache to rewrite an URL that references a file name register.jsp to an HTTPS URL.

Add a statement similar to this one to your httpd.conf file for your particular case.

This module is complex for some people so see the mod_rewrite module documentation on
You may also need or be interested in Apache IP Based Virtual Hosting since SSL won't run on a named based virtual host. See for virtual hosting.

You may also require an Aliased IP address. If you SSL virtual host is on the same machine as your main server then you need a second NIC card. You can work around this by assigning an aliased IP address to your current NIC. Essentially, this assigns your NIC an additional (aliased) IP address. This second address is then used by the SSL virtual host by assigning it in the httpd.conf.

You also need a DNS entry for your virtual host.
 
I do agree that this is a possible way to go. I just think that this may be too complex for a simple request or for a novice Apache user.



-DJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top