943,917 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1008
  • PHP RSS
Aug 4th, 2009
0

Need a 301 redirect script for php to html

Expand Post »
Hi I am running on hosts shared server - windows 2003 with IIS 6 and apache but they can't redirect in IIS as its shared and I have no .htaccess rights even if I did my hosts say it is very limited. I also have front page server extensions installed. They said I have to use scripts to do the 301 redirect my pages are HTML but meta refresh and javascripts are a big no go areas with SEO.

I need a 301 redirect script for SEO so that I can redirect non-www version to www.mysite.com

All my files are html with .htm extension and I am a complete newb to PHP but googled some PHP scripts and tested but none worked. I even duplicated index.htm to index.php and coded in there but couldn't get that to work either.

I posted similar in web developing HTML section of this forum but no luck there so far.

PLEASE HELP! I am now loosing much sleep over this problem. Thank you in advance.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decay is offline Offline
17 posts
since Aug 2009
Aug 5th, 2009
0

Re: Need a 301 redirect script for php to html

php Syntax (Toggle Plain Text)
  1. <?
  2. header( "HTTP/1.1 301 Moved Permanently" );
  3. header( "Location: http://www.your-new-site.com/your-new-url.html" );
  4. ?>
PoA
Reputation Points: 19
Solved Threads: 9
Posting Whiz in Training
PoA is offline Offline
234 posts
since Jul 2004
Aug 5th, 2009
0

Re: Need a 301 redirect script for php to html

Thankyou for the code and syntax but now I do not know what to do with it. Do I simply paste the code at the top of my index.htm file above the headers or do I need to make a new duplicate index.htm and name it index.php and only have the code in this file? If so how does the server pick up the php file and not the htm file?

My new site is the same as my old site only it has www. in front of it. Infact it is the same site all together but just the reference on the server.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decay is offline Offline
17 posts
since Aug 2009
Aug 5th, 2009
0

Re: Need a 301 redirect script for php to html

Well, if the page is .htm and the server is not set up to parse php in .htm files, just use a meta refresh:
html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <meta http-equiv="refresh" content="2;url=http://www.yoursite.com/newpage.htm" />
  4. <title>Page has moved</title>
  5. </head>
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Aug 6th, 2009
0

Re: Need a 301 redirect script for php to html

Hi thank you for the reply however I can not use a meta refresh as the status code 301 will not get returned and I will get peanalised SEO wise. Also my page ranking will not get carried over. People say NEVER use a meta refresh. Javascript in html is also highly recommended against.

I am not sure what the server can or can not do I was meerly asking my host about .htaccess and he said it has very basic functionality on their setup and mentioned it can not do something with PHP however seen as I do not know PHP i did not understand what he said. I am guessing he meant what you said.

I know that when I went into my very basic control panel I found I have option 2 and I am paying an extra £10 pa for this option but get FPSE and this also gives me scripting options using PHP, ASP and ASP.net

I do not know either but am quite sure there must be a PHP script I can use but I do not know how to use it even if I have the code.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decay is offline Offline
17 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how write div with in div elements in pdf using php
Next Thread in PHP Forum Timeline: Php script accessing the default table..?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC