Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Specific file htaccess HTTPS redirect
Old 08-01-2008, 05:23 PM Specific file htaccess HTTPS redirect
Super Talker

Posts: 116
Trades: 0
I'm a complete neophyte at using the .htaccess file, but I know that you can do redirections and stuff with it. Now, I want to switch between http and https depending on what file is requested. If they go to the index of the site (http://www.mysitememberships.com OR http://www.mysitememberships.com/index.php), I want it to stay as http. However, if they go to any of, say 4, specific pages, I want it to switch over to https (pages would be /myadd.php, /myedit.php, /myview.php, /userlogin.php, /controlpanel.php). However, after they visit that page and it switches over to https, I would like it to switch back to http if they request a page that is not part of that list (such as going back to the index).

How would I go about doing this?
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
 
Register now for full access!
Old 08-01-2008, 07:54 PM Re: Specific file htaccess HTTPS redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,528
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use absolute links instead of relative to the secure pages and on the secure pages back to the main site.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-01-2008, 08:35 PM Re: Specific file htaccess HTTPS redirect
Super Talker

Posts: 116
Trades: 0
i try to avoid absolute links at all costs, is there like any way at all to do this solely through htaccess? (i'll use absolute links in htaccess if needed, i just try not to use absolute links on my pages incase i ever need to change domain names etc. i also have multiple domain names so its better that i don't use them).

thanks for the suggestion and the thread move chris
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
Old 08-02-2008, 12:43 PM Re: Specific file htaccess HTTPS redirect
L a r r y's Avatar
Super Talker

Posts: 100
Name: Larry K
Location: Arizona
Trades: 0
I am thinking that if you follow Chris' sound advice, and find yourself changing domain names, you have to edit maybe 50 different links pointing to 4 secure pages, and however many links pointing from the secure pages, scattered across your site.

You use relative paths among your nonsecure pages and use relative paths among your secure pages, but need to use absolute paths between the two groups.

I think you could do this using htaccess Redirects, but you would in each case want to create relative links that point to nonexistent places for each absolute link.

For each link from http to https, and for each link from https to http, select a path to nowhere for use in your link tag, and add a corresponding Redirect to your htaccess in the root of the web site:

Redirect /does-not-exist-https-page1/ https://example.com/page1/

and going the other way,

Redirect /does-not-exist-http-page23/ http://example.com/page23/

Now, if you change domain names, you just need to edit one htaccess file to make the changes complete.

Do not link to an actual page with the relative links to the opposite secure/nonsecure pages, for if you do, ALL links to that page will become absolute links by way of the redirect, which would put an extra burden on your server.

My site uses a separate folder for each page in most instances, and therefore, I have Web addresses that end in example.com/ and example.com/members/. This keeps outside links to a page valid even if I choose to use index.cgi or index.php instead of index.shtml. In case you point to pages instead of folders, then your Redirect would look like this:

Redirect /does-not-exist-https-page32.html https://example.com/page32.html
L a r r y is offline
Reply With Quote
View Public Profile Visit L a r r y's homepage!
 
Reply     « Reply to Specific file htaccess HTTPS redirect
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14524 seconds with 12 queries