Jump to content

Recommended Posts

i've pasted the suggested code into the top of the script.php file. but i get the following error when i go to the http://www.mysite.com/script.php

 

Warning: Cannot modify header information - headers already sent by (output started at C:\web\www.mysite.com\script.php:1)

 

anyone know what this means? what i can do?

it means you already sent code to to client. headers are the first thing to be sent, and must be output to the client before anything else. but i'm assuming you're echoing a "you're being redirected" msg or something similar. just move the header() up to before you output anything else. however, i'm not sure anything after that will get displayed...

A lot of people say that you should always place headers at the top of the page. This is not entirely true. You should structure your code and display everything at the end of the page, not in little droplets. A lot of people echo on the fly, then encounter header errors so they use output buffering. Output buffering is not a solution, merely a bandage to hide the wound. Properly structured code will eliminate header errors.

I did. you can see the code below...

 

<?php
header('Location: https://www.mysite.com/script.php');
?>
<form name="upload-form" id="upload-form" method="post" action="./upload.php" enctype="multipart/form-data"> 
  <input type="hidden" name="MAX_FILE_SIZE" value="1024000"> 
  <fieldset> 
  <legend>File upload:</legend> 

  <dl> 

<dt> 
      <label for="file">File:</label> 
    </dt> 
    <dd> 
      <input tabindex="1" accesskey="b" name="file" type="file" id="file" /> 
    </dd> 
  </dl> 
  <input tabindex="2" accesskey="l" type="submit" name="cmdupload" value="Upload" /> 
  </fieldset> 
</form>

I added the suggested code to my httpd.conf file in the <location> block, removed the comment # and rebootet the server. But it didn't work. where should i put the .htaccess file in order to try that.

 

I'm starting to get a bit annoyed at this, to think something that sounds so easy could be so frustrating.

Forget the header command or any other type of script redirect (could ruin Google rankings). Use a proper 301 redirect in your .htaccess as DanielO suggested.

 

RewriteEngine on

RewriteCond {%HTTPS} !on

Rewriterule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.