• Super User

    errore redirect 301

    ciao a tutti,
    devo fare un redirect 301 in php ma non riesco e mi da sempre errore... ho provato in questi modi:

    <?
    Header( ?HTTP/1.1 301 Moved Permanently? );
    Header( ?Location: http://www.nuovourl.com? );
    ?>

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.newdomain.com/page.html");
    exit();
    ?>

    Ma purtroppo mi danno sempre errore

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6) in /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php on line 7

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6)

    Inutile dire che ho tentato anche facendo htaccess ma dopo aver telefonato al hosting mi hanno detto che in questo modo non posso farlo quindi di fare solamente una pagina di reindirizzamento in php

    Ora come posso risolvere questo problema?

    Ciao e grazie tutti del vostro preziosissimo aiuto

    :ciauz: [/code]


  • Super User

    ciao a tutti,
    devo fare un redirect 301 in php ma non riesco e mi da sempre errore... ho provato in questi modi:

    <?
    Header( ?HTTP/1.1 301 Moved Permanently? );
    Header( ?Location: http://www.nuovourl.com? );
    ?>

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.newdomain.com/page.html");
    exit();
    ?>

    Ma purtroppo mi danno sempre errore

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6) in /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php on line 7

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6)

    Inutile dire che ho tentato anche facendo htaccess ma dopo aver telefonato al hosting mi hanno detto che in questo modo non posso farlo quindi di fare solamente una pagina di reindirizzamento in php

    Ora come posso risolvere questo problema?

    Ciao e grazie tutti del vostro preziosissimo aiuto

    :ciauz:


  • Super User

    eccomi... 😄

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6) in /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php on line 7

    Warning: Cannot add header information - headers already sent by (output started at /usr/home/italmarket/httpd/htdocs/cs/hotelzilema/hotelzilema/index.php:6)

    deve essere il primo output del server, prima di ogni altra cosa o riga vuota.... controlla 😄


  • Super User

    cosa dovrei controllare? Tieni presente che non ho i comandi lato server e quindi non posso agire da quella parte...

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Documento senza titolo</title>
    <?php
    header&#40;"HTTP/1.1 301 Moved Permanently"&#41;;
    header&#40;"Location&#58; http&#58;//www.hotelzilema.it/index.html"&#41;;
    exit&#40;&#41;;
    ?>
    </head>
    <body>
    Reindirizzamento in corso...
    </body>
    </html>
    
    

    Questo qui sopra è tutto il codice della pagina...

    Grazie a tutti

    :ciauz:


  • Super User

    mi sa che non lo devi mettere nell'head, ma proprio prima di qualsiasi altro codice.


  • Super User

    @Josie said:

    mi sa che non lo devi mettere nell'head, ma proprio prima di qualsiasi altro codice.
    si, come prima riga del file.... 🙂


  • Super User

    avevi perfettamente ragione! Adesso funziona!

    Grazie molte a tutti quanti

    :ciauz: