Headers sent 301 - Browser won't redirect - [FIXED]

Zero duplicate support forum.
Personalized HTTP 301 dynamic redirections.

Moderator: Moderators

Headers sent 301 - Browser won't redirect - [FIXED]

Postby visio » Thu May 31, 2007 7:50 pm

Hi, I installed the zero dup mod, everything seems fine except the old urls won't redirect for me in my browser(IE or FF)

Here are a few old ones:

http://www.1stsearchenginerankings.com/ ... .php?t=244
http://www.1stsearchenginerankings.com/ ... um.php?f=3

If I look them up with websniffer it says the headers are sent 301. Check yourself if you like.

But in my browsers it won't redirect me. I user 301s all the time and have no trouble so it isn't that.

Got any ideas?

Also I don't want to stick the link in the global footer. I tried the index.php but it didn't show up. Can you give me an idea how to stick it in the index file so it shows up on the home page only?

Thanks, Randy
Last edited by visio on Wed Jun 06, 2007 5:14 pm, edited 1 time in total.
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Advertisement

Postby SeO » Thu May 31, 2007 8:28 pm

http://www.1stsearchenginerankings.com/forums/viewtopic.php?t=244
Code: Select all
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Location:   http://1stsearchenginerankings.com/forums/what-is-this-called-t244.html   
Connection:   close   
Transfer-Encoding:   chunked   
Content-Type:   text/html


The target misses the www, so with redirecting to force the www prefix this can loop and fail.
You need to set you phpBB config right eg "www.1stsearchenginerankings.com" for the domain name in acp.

Besides, headers are correct, so it should not be more tricky than this, which is kind of tricky ;)
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm

Postby visio » Thu May 31, 2007 11:33 pm

Hmm so you mean login to the admin and change the config... I think it is already set the way you said but I will check...

Wait I can't. When i try and login I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/search/public_html/forums/index.php:1) in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 295

Warning: Cannot modify header information - headers already sent by (output started at /home/search/public_html/forums/index.php:1) in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 296

Ohh no. I thought I was done with that. Any ideas what is wrong?

Thanks a million!
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby dcz » Fri Jun 01, 2007 9:28 am

This is actually the same problem I think, get rid of the www prefix redirection for a minute, and you'll be able to go to ACP, because while you loginto acp, you're redirected to the domain set up in acp as well, thus here without the www prefix which activates the www prefix redirection.

You can as well directly edit the phpbb_config table using phpmyadmin, the sitename value ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby visio » Sun Jun 03, 2007 7:50 pm

I reset the files and then went into the general config in admin and changed domain name to www.1stsearchenginerankings.com

I then re-uploaded the files and I still get the same error when attempting login. Good news though, the old files do now redirect to the new files. Now I just need to figure out how to fix the login problem which still gives this error:

Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/search/public_html/forums/index.php:1) in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 295

Warning: Cannot modify header information - headers already sent by (output started at /home/search/public_html/forums/index.php:1) in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 296



Here is my .htaccess file:

Code: Select all
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#########################################################
# PHPBB SEO REWRITE RULES #
#########################################################
# AUTHOR : DCZ http://www.phpbb-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM INDEX (un-comment if used)
# RewriteRule ^forums/index\.html$ /forums/index.php [QSA,L,NC]
# FORUM PROTECTION RULE
# RewriteRule ^forums/[a-z0-9_-]*/([^/]+\.html)$ /forums/index.php [R=301,L,NC]
# CATEGORIES
RewriteRule ^forums/[a-z0-9_-]*-c([0-9]+)\.html$ /forums/index.php?c=$1 [QSA,L,NC]
# PAGINATED FORUM
RewriteRule ^forums/[a-z0-9_-]*-f([0-9]+)-([0-9]+)\.html$ /forums/viewforum.php?f=$1&start=$2 [QSA,L,NC]
# FORUM
RewriteRule ^forums/[a-z0-9_-]*-f([0-9]+)\.html$ /forums/viewforum.php?f=$1 [QSA,L,NC]
# PAGINATED TOPIC
RewriteRule ^forums/[a-z0-9_-]*-t([0-9]+)-([0-9]+)\.html$ /forums/viewtopic.php?t=$1&start=$2 [QSA,L,NC]
# TOPIC
RewriteRule ^forums/[a-z0-9_-]*-t([0-9]+)\.html$ /forums/viewtopic.php?t=$1 [QSA,L,NC]
# POST
RewriteRule ^forums/post([0-9]+)\.html$ /forums/viewtopic.php?p=$1 [QSA,L,NC]
#PROFILES
RewriteRule ^forums/member([0-9]+)\.html$ /forums/profile.php?mode=viewprofile&u=$1 [QSA,L,NC]
# END PHPBB PAGES
#####################################################

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.1stsearchenginerankings.com
AuthUserFile /home/search/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/search/public_html/_vti_pvt/service.grp

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^1stsearchenginerankings.com [NC]
RewriteRule ^(.*)$ http://www.1stsearchenginerankings.com/$1 [L,R=301]


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

AddType application/x-httpd-php5 .php



OKAY HERES THE DEAL! Since the admins here seem to give free help I am willing to give one of them $15 via paypal(easy money for someone knowing what they are doing) to take a look at fix the problem for me.

ADDED: What I mean is FTP access so it can be fixed. Please send me a email at randy[at}1st-rankings.com if you will do this for me. It would be a big help!

Thanks for all your help!
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby dcz » Sun Jun 03, 2007 9:23 pm

First, you should not start mod rewrite more than once.
And the www prefix redirection should be the first one of all.

So find :

Code: Select all
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /


And after add :
Code: Select all
RewriteCond %{HTTP_HOST} ^1stsearchenginerankings.com [NC]
RewriteRule ^(.*)$ http://www.1stsearchenginerankings.com/$1 [L,R=301]


And then delete :
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^1stsearchenginerankings.com [NC]
RewriteRule ^(.*)$ http://www.1stsearchenginerankings.com/$1 [L,R=301]


As well as :
Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


Apears two times, and the last occurence of :
Code: Select all
RewriteEngine On
RewriteBase /



Then, about the error you get, it is strange. Could you post here the code you have in phpbb_seo_class.php file, not all of it, just the code around line 295 (+- 10 lines lets say).

If it is the files end, there may be an extra space after the ending php tag : ?>
Make sure there isn't any, but I doubt.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby visio » Sun Jun 03, 2007 10:40 pm

phpbb_seo file:

Code: Select all
// --> Zero Duplicate
   /**
   * Custom HTTP 301 redirections.
   * To kill duplicates
   */
   function seo_redirect($url, $header = "301 Moved Permanently", $code = 301, $replace = TRUE) {
      global $db;
      if ( !empty($db) ) {
         $db->sql_close();
      }
      if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r") || strstr(urldecode($url), ';url')) {
         message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
      }
      $http = (@function_exists("getallheaders")) ? "HTTP/1.1 " : "Status: ";
      header($http . $header, $replace, $code);
      header("Location:" . $url);
      exit();
   }
   /**
   * Helps out grabbing boolean vars
   */
   function seo_cond($bool = FALSE, $or = FALSE) {
      if ( $bool || ($this->do_redir && $or) ) {
         $this->do_redir = TRUE;
      }
      return;
   }
   /**
   * Returns the REQUEST_URI
   */
   function seo_req_uri() {
      // Apache mod_rewrite
      if ( isset($_SERVER['REQUEST_URI']) ) {
         return $_SERVER['REQUEST_URI'];
      }
      // IIS  isapi_rewrite
      if ( isset($_SERVER['HTTP_X_REWRITE_URL']) ) {
         return $_SERVER['HTTP_X_REWRITE_URL'];
      }
      // no mod rewrite
      return  $_SERVER['SCRIPT_NAME'] . ( ( isset($_SERVER['QUERY_STRING']) ) ? '?'.$_SERVER['QUERY_STRING'] : "" );
   }

?>



After removing the space from the end of the file I NOW get this error:

Code: Select all
Parse error: syntax error, unexpected '}' in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 322
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby SeO » Mon Jun 04, 2007 7:06 am

Well, it as well looks like you are missing the seo_start() method, look again the last part of the zero dupe install. The last instruction.

As well, dcz mentioned spaces after ?>, no the } before.
SeO
Admin
Admin
 
Posts: 6333
Joined: Wed Mar 15, 2006 9:41 pm

Postby visio » Mon Jun 04, 2007 3:51 pm

I looked over and couldn't find any problems.

I don't know what happened but the urls aren't redirecting anymore either. They give the same error:


Code: Select all
Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /home/search/public_html/forums/phpbb_seo/phpbb_seo_class.php on line 334



This is what my phpbb_seo file looks like now:

Code: Select all
// --> Zero Duplicate
   /**
   * Custom HTTP 301 redirections.
   * To kill duplicates
   */
   function seo_redirect($url, $header = "301 Moved Permanently", $code = 301, $replace = TRUE) {
      global $db;
      if ( !empty($db) ) {
         $db->sql_close();
      }
      if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r") || strstr(urldecode($url), ';url')) {
         message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
      }
      $http = (@function_exists("getallheaders")) ? "HTTP/1.1 " : "Status: ";
      //header($http . $header, $replace, $code);
      //header("Location:" . $url);
      exit();
   }
   /**
   * Helps out grabbing boolean vars
   */
   function seo_cond($bool = FALSE, $or = FALSE) {
      if ( $bool || ($this->do_redir && $or) ) {
         $this->do_redir = TRUE;
      }
      return;
   }
   /**
   * Returns the REQUEST_URI
   */
   function seo_req_uri() {
      // Apache mod_rewrite
      if ( isset($_SERVER['REQUEST_URI']) ) {
         return $_SERVER['REQUEST_URI'];
      }
      // IIS  isapi_rewrite
      if ( isset($_SERVER['HTTP_X_REWRITE_URL']) ) {
         return $_SERVER['HTTP_X_REWRITE_URL'];
      }
      // no mod rewrite
      return  $_SERVER['SCRIPT_NAME'] . ( ( isset($_SERVER['QUERY_STRING']) ) ? '?'.$_SERVER['QUERY_STRING'] : "" );
   }
/**
   * check start var consistency
   */
   function seo_start($start = 0, $limit = 0) {
      if ($limit > 0) {
         $start = ( is_int( $start/$limit ) ) ? $start : intval($start/$limit)*$limit;
         $this->start = ( $start > 0  ) ? $this->seo_static['start'] . $start : '';
      } else {
         $this->start = ( $start > 0  ) ? $this->seo_static['start'] . $start : '';
      }
   }
?>



I just can't seem to figure out what is wrong. If I add another T-Function to the end like such: }?> it allows me to view the forums but I can't login and the urls still don't redirect.
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby dcz » Mon Jun 04, 2007 6:05 pm

SeO wrote:As well, dcz mentioned spaces after ?>, no the } before.


Replace :

Code: Select all
?>


With :
Code: Select all
}
?>


To start with.

Have you updated your .htaccess as advised ?

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby visio » Mon Jun 04, 2007 6:36 pm

Okay done... after changing the ?> tag when trying to login it now goes to http://www.1stsearchenginerankings.com/forums/index.php but does not give an error and the forums don't load just the added test I place at the top of the screen to notify users there was a problem with the forums.
If you just browse the forums everything works but you can't login still.

I did update the .htaccess before and it now looks like this:

Code: Select all
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^1stsearchenginerankings.com [NC]
RewriteRule ^(.*)$ http://www.1stsearchenginerankings.com/$1 [L,R=301]

#########################################################
# PHPBB SEO REWRITE RULES #
#########################################################
# AUTHOR : DCZ http://www.phpbb-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM INDEX (un-comment if used)
# RewriteRule ^forums/index\.html$ /forums/index.php [QSA,L,NC]
# FORUM PROTECTION RULE
# RewriteRule ^forums/[a-z0-9_-]*/([^/]+\.html)$ /forums/index.php [R=301,L,NC]
# CATEGORIES
RewriteRule ^forums/[a-z0-9_-]*-c([0-9]+)\.html$ /forums/index.php?c=$1 [QSA,L,NC]
# PAGINATED FORUM
RewriteRule ^forums/[a-z0-9_-]*-f([0-9]+)-([0-9]+)\.html$ /forums/viewforum.php?f=$1&start=$2 [QSA,L,NC]
# FORUM
RewriteRule ^forums/[a-z0-9_-]*-f([0-9]+)\.html$ /forums/viewforum.php?f=$1 [QSA,L,NC]
# PAGINATED TOPIC
RewriteRule ^forums/[a-z0-9_-]*-t([0-9]+)-([0-9]+)\.html$ /forums/viewtopic.php?t=$1&start=$2 [QSA,L,NC]
# TOPIC
RewriteRule ^forums/[a-z0-9_-]*-t([0-9]+)\.html$ /forums/viewtopic.php?t=$1 [QSA,L,NC]
# POST
RewriteRule ^forums/post([0-9]+)\.html$ /forums/viewtopic.php?p=$1 [QSA,L,NC]
#PROFILES
RewriteRule ^forums/member([0-9]+)\.html$ /forums/profile.php?mode=viewprofile&u=$1 [QSA,L,NC]
# END PHPBB PAGES
#####################################################

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.1stsearchenginerankings.com
AuthUserFile /home/search/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/search/public_html/_vti_pvt/service.grp


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

AddType application/x-httpd-php5 .php
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby dcz » Mon Jun 04, 2007 6:55 pm

All right, this is not really related to your issue, but still, would be better if you replace :


Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


With:
Code: Select all
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


In your .htaccess.

Then, the way thing turns makes it difficult to support, because it as well seems you could have only missed a part of the install.

I suggest you start a test board and start installing first the mod rewrite from scratch, and then, once everything is working, including login, add the zero dupe.

It looks like you have backups of your file just before you started to install mod rewrite and the zero dupe, if the login is working at this stage, redoing it from scratch would probably be really faster than trying to find out about this really strange issue (never saw a login problem with these).

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm

Postby visio » Mon Jun 04, 2007 7:06 pm

Hmm maybe your right.
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby visio » Wed Jun 06, 2007 5:12 pm

Okay I FIGURED IT OUT!!!!!

Here was the problem. If you have removed sessions before using this mod you can have a problem. That was mine. So I installed a test board and used those files(be careful if you got other mods) and it worked.

I then got this problem where I couldn't login. This was caused by the cookie settings in admin general config. Change cookie domain to:
.domain.com
NO http:// or www prefix just the DOT


So it is all fixed now. Thanks alot!
visio
 
Posts: 22
Joined: Thu May 31, 2007 6:27 pm

Postby dcz » Wed Jun 06, 2007 8:41 pm

Great :D
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm


Return to Zero duplicate phpBB2

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 2 guests