mtylerb Posted November 17, 2008 Share Posted November 17, 2008 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: <?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: 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. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/ Share on other sites More sharing options...
premiso Posted November 17, 2008 Share Posted November 17, 2008 Your server is not setup to parse .xhtml as php. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692346 Share on other sites More sharing options...
Mchl Posted November 17, 2008 Share Posted November 17, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692350 Share on other sites More sharing options...
mtylerb Posted November 17, 2008 Author Share Posted November 17, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692352 Share on other sites More sharing options...
premiso Posted November 17, 2008 Share Posted November 17, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692357 Share on other sites More sharing options...
Mchl Posted November 17, 2008 Share Posted November 17, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692361 Share on other sites More sharing options...
mtylerb Posted November 17, 2008 Author Share Posted November 17, 2008 Ok, thank you, I figured out the .htaccess thing. Just placed the following code in and it worked perfectly: 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: 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? Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692369 Share on other sites More sharing options...
mtylerb Posted November 17, 2008 Author Share Posted November 17, 2008 I posted that last addition as an Edit, this is just to let you know I replied. Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692382 Share on other sites More sharing options...
mtylerb Posted November 18, 2008 Author Share Posted November 18, 2008 I noticed this has been moved to a new board. Does anyone over here have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692618 Share on other sites More sharing options...
mtylerb Posted November 18, 2008 Author Share Posted November 18, 2008 Ok, after playing around, I got it. Changed my .htaccess to: 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? Quote Link to comment https://forums.phpfreaks.com/topic/133132-solved-unhelpful-error/#findComment-692624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.