i have this apache-php server runing with some php and mysql apps..
I also have this application that uses java and one module is running through RMI, and its automatically started by the init.d using a shell script...
then it's visible through a port (which is configured on the module java config file):

http://severipaddress:2000

I would like to know if there's a way to tell apache that i need this port to be secured through htaccess so a user / password can be asked before enter the application in:

http://severipaddress:2000

Is that possible?

Okay I just thought you can't use apache rewrite module.

Maybe you need to use PHP to ask what the URL is and then use the PHP header to redirect it to the url with the port on the end.

and how can i do that?
I also think i may be able to use .htaccess rewrite module, i just don't know how to make that happen..

when i access the http:// server:port, it loads the java app, before that, i need apache to ask for authentication.. then load the app.. is it possible to use rewrite module to do that?

i dunno if php can do it, since i have no way to redirect to the app other than the address http:// server:port and that's what im trying to secure...

if you want to allow access your website through secure http only, then putting this code in the htaccess will do that -

IndexIgnore *
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

it will rewrite all your url from http to https also.though i haven't tested it , I am sure it should work.

if you want to allow access your website through secure http only, then putting this code in the htaccess will do that -

IndexIgnore *
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

it will rewrite all your url from http to https also.though i haven't tested it , I am sure it should work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.