homepage Welcome to WebmasterWorld Guest from 54.237.99.131
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
need help with htaccess to stop https redirect on 1 specific file
tfurber

5+ Year Member



 
Msg#: 4515368 posted 2:00 pm on Nov 3, 2012 (gmt 0)

I have a need to stop the https redirect that apache seems to be performing on all files, but only on one specific .php file. Its necessary because im port forwarding through a firewall to reach just 1 specific file on the apache machine from the outside world. When it redirects to 443/https it messes this up. Can anyone assist?

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4515368 posted 2:09 pm on Nov 3, 2012 (gmt 0)

In the rule that redirects add a preceding RewriteCond testing for that one specific URL request.

tfurber

5+ Year Member



 
Msg#: 4515368 posted 3:10 pm on Nov 3, 2012 (gmt 0)

There is no rule that redirects that i can see. I think its buried somewhere in the http conf files. I just need another rule that exempts a certain file or directory from the default rule.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4515368 posted 3:17 pm on Nov 3, 2012 (gmt 0)

There is no rule that redirects that I can see.

There must be one, because of...
When it redirects to 443/https it messes this up.

In the rule that redirects add a preceding RewriteCond testing for that one specific URL request.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4515368 posted 8:49 am on Nov 4, 2012 (gmt 0)

welcome to WebmasterWorld, tfurber!


When it redirects to 443/https it messes this up.

is that a technical description?
=8)

install the Live HTTP Headers add-on for firefox and you will be able to see all HTTP Request and Response headers and the response status chain.
report what you see.
most interesting is the request and status code of the response:
GET http...
200 OK

and if the response is a 301/302, the Location: header.

when you post, Please Use Example.com For Your Domain Name:
http://www.webmasterworld.com/apache/4452736.htm [webmasterworld.com]


There is no rule that redirects that i can see. I think its buried somewhere in the http conf files. I just need another rule that exempts a certain file or directory from the default rule.

you need to find this rule because you must implement the exemption where the rule originates the redirect.

you must also have a rule to redirect https:/:443 requests for non-secure resources to the http: protocol.

tfurber

5+ Year Member



 
Msg#: 4515368 posted 7:26 pm on Nov 5, 2012 (gmt 0)

I see this in one of the http conf files, but i need some help in what todo though. This looks like it redirects all.

<Directory "/var/www/html">
# Redirect administration interface to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4515368 posted 7:33 pm on Nov 5, 2012 (gmt 0)

Add another RewriteCond looking at either THE_REQUEST or REQUEST_URI

Add it after the RewriteCond and before the RewriteRule.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4515368 posted 12:31 am on Nov 6, 2012 (gmt 0)

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

... and where it says %{HTTP_HOST} you will, of course, substitute one specific canonical form of your domain name.

(g1 meant to say this, but he forgot ;))

tfurber

5+ Year Member



 
Msg#: 4515368 posted 8:37 pm on Nov 6, 2012 (gmt 0)

you guys arent much of a help, i need an example

tfurber

5+ Year Member



 
Msg#: 4515368 posted 8:45 pm on Nov 6, 2012 (gmt 0)

this works for the specific file but breaks everything else

<Directory "/var/www/html">
# Redirect administration interface to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (web_to_lead.php) - [L]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Directory>

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4515368 posted 10:46 pm on Nov 6, 2012 (gmt 0)

Now, wait. Are you in htaccess or in the config file? The thread title says htaccess, but you've been talking about the config file-- and <Directory> envelopes in htaccess will break the whole site. (I'm not taking apache's unsupported word. I tested it on my spare site. Splat! Straight to a 500.)

Either way, since you're talking about one individual file, what's <Directory> for? If you're using an envelope at all, it should be <Files>.

Want the boilerplate on Why We Make You Do It Yourself? I've got a copy somewhere.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved