Author Topic: [SOLVED] Unhelpful Error  (Read 874 times)

0 Members and 1 Guest are viewing this topic.

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
[SOLVED] Unhelpful Error
« on: November 17, 2008, 05:45:07 PM »
Hey guys,

I have a file that has moved and I'm trying to set up, what should be, a simple PHP header redirect.  In my file at http://www.tbeckett.net/plugins.xhtml I'm using the following code:

Code: [Select]
<?php

header
("HTTP/1.0 301 Moved Permanently");
header("Status: 301 Moved Permanently");

header("Location: http://www.tbeckett.net/articles/plugins.xhtml");

?>

But I only seem to get an error when I try to open that:

Quote
XML Parsing Error: no element found
Location: http://www.tbeckett.net/plugins.xhtml
Line Number 8, Column 3

:?>
--^

Can anyone help me with this?  I have the exact same script running in a number of other files, since I changed the structure of my page, they all work fine, it's just this one.
« Last Edit: November 17, 2008, 05:46:42 PM by mtylerb »
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!

Offline premiso

  • Karma Chameleon
  • Staff Alumni
  • Freak!
  • *
  • Posts: 6,671
  • Gender: Female
  • effing right
    • View Profile
    • PHP Help
Re: Unhelpful Error
« Reply #1 on: November 17, 2008, 05:46:12 PM »
Your server is not setup to parse .xhtml as php.

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Unhelpful Error
« Reply #2 on: November 17, 2008, 05:48:08 PM »
Look up source of this file in browser, to see what's causing it.

My bet is... your php code did not run, because the file has xhtml extension. You should use mod_rewrite, to rewrite plugins.xhtml.php into plugins.xhtml

[edit]

Or as premiso says, configure your server, to parse .xhtml files as php... I'm not sure if it's good idea though.

« Last Edit: November 17, 2008, 05:49:03 PM by Mchl »
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
Re: Unhelpful Error
« Reply #3 on: November 17, 2008, 05:49:15 PM »
Is there a way to fix this?  The other files are all xhtml as well, for example,

http://www.tbeckett.net/articles/libertarianism.xhtml

Redirects to

http://www.tbeckett.net/articles/politics/libertarianism.xhtml

With no trouble.

EDIT:  Ok, you've offered ways to fix it, sorry, missed that.  How would I do that with mod_rewrite?  I already use mod_rewrite to remove the question mark from the url.  I didn't design it though and the original 301 redirects that were put in the .htaccess never worked.
« Last Edit: November 17, 2008, 05:53:34 PM by mtylerb »
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!

Offline premiso

  • Karma Chameleon
  • Staff Alumni
  • Freak!
  • *
  • Posts: 6,671
  • Gender: Female
  • effing right
    • View Profile
    • PHP Help
Re: Unhelpful Error
« Reply #4 on: November 17, 2008, 05:51:53 PM »
Look up source of this file in browser, to see what's causing it.

My bet is... your php code did not run, because the file has xhtml extension. You should use mod_rewrite, to rewrite plugins.xhtml.php into plugins.xhtml

[edit]

Or as premiso says, configure your server, to parse .xhtml files as php... I'm not sure if it's good idea though.



Sorry I was not hinting that he should change his server to parse .xhtml as php. Should have been clearer on it.

mod_rewrite would be better, that way you would not have to create a file plugins.xhtml, or you could even have the .htaccess do the redirect for you.

http://www.isitebuild.com/301-redirect.htm

Will help with the .htaccess 301 redirect.

Offline Mchl

  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,582
  • Gender: Male
  • That's Largo in my avatar, not me.
    • View Profile
    • FlingBits
Re: Unhelpful Error
« Reply #5 on: November 17, 2008, 05:53:45 PM »
Sorry I was not hinting that he should change his server to parse .xhtml as php. Should have been clearer on it.

My fault. You didn't say that. You said taht his server wasn't configured this way. Sorry ;)
NetBeans fanatic | ExtJS masochist | C++ denier
PHP4 & MySQL4 are no longer supported.
PHPFreaks Tutorials | PHP Debugging: A Beginner's guide | PHP Security Tutorial || How To Ask Questions The Smart Way
Flingbits tutorials | Class Autoloading

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
Re: Unhelpful Error
« Reply #6 on: November 17, 2008, 05:59:07 PM »
Ok, thank you, I figured out the .htaccess thing.  Just placed the following code in and it worked perfectly:

Code: [Select]
redirect 301 /plugins.xhtml http://www.tbeckett.net/articles/plugins.xhtml
I don't know why it didn't work before.  Thanks for your help Mchl and premiso!

EDIT:  Actually, I just noticed that it's now sending me to:  http://www.tbeckett.net/articles/plugins.xhtml?plugins.xhtml

My .htaccess looks like:

Code: [Select]
Options +FollowSymLinks
AddDefaultCharset UTF-8
redirect 301 /plugins.xhtml http://www.tbeckett.net/articles/plugins.xhtml

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Administration URL rewriting.
  RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Main URL rewriting.
  RewriteRule ^(.*)$ index.php?$1 [L,QSA]
</IfModule>

Any ideas?
« Last Edit: November 17, 2008, 06:07:22 PM by mtylerb »
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
Re: Unhelpful Error
« Reply #7 on: November 17, 2008, 06:12:29 PM »
I posted that last addition as an Edit, this is just to let you know I replied.
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
Re: Unhelpful Error
« Reply #8 on: November 18, 2008, 07:03:45 AM »
I noticed this has been moved to a new board.  Does anyone over here have any ideas?
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!

Offline mtylerbTopic starter

  • Enthusiast
  • Posts: 69
  • Gender: Male
    • View Profile
    • Tyler's Site
Re: Unhelpful Error
« Reply #9 on: November 18, 2008, 07:25:38 AM »
Ok, after playing around, I got it.  Changed my .htaccess to:

Code: [Select]
Options +FollowSymLinks
AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
 
  RewriteRule ^plugins.xhtml articles/plugins.xhtml [R=permanent,L]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Administration URL rewriting.
  RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  # Main URL rewriting.
  RewriteRule ^(.*)$ index.php?$1 [L,QSA]


</IfModule>

Adding that first RewriteRule in.  While you're reading this, could someone tell me what the !-l, !-f, and !-d mean?
I may be useless, but I'll try anyway!

The name is pronounced Em Tyler Bee,
But just Tyler will do nicely!