RE: [PHP-INST] Need help putting a small pice of code on an html page
| From: | Joerg Aldinger | Date: | Thu, 09 Jan 2003 14:12:49 +0000 |
| Subject: | RE: [PHP-INST] Need help putting a small pice of code on an html page | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-9644@lists.php.net to get a copy of this message | ||
Mike,
the method discussed in this thread works only if the
original page already is a PHP page. Note that the
statement is included in <?php ... ?> brackets,
which indicates PHP code. It would not work in
HTML files.
Joerg.
-----Original Message-----
From: Mike Young [mailto:mikeyoung80@yahoo.com]
Sent: Thursday, January 09, 2003 10:02 AM
To: php-install@lists.php.net
Subject: RE: [PHP-INST] Need help putting a small pice of code on an html
page
I found a post a codingforums.com where someone is
asking how to pull php scripts from another directory.
http://www.codingforums.com/showthread.php?s=&threadid=12506
--- Joerg Aldinger <jaldinger@consulturdorado.com>
wrote:
> Mike,
>
> there are several solutions to your problem. Here
> are a few:
>
> ******** 1) Redirect visitors to the new page
> To do this, create/modify a .htaccess file in the
> directory where your old
> page is and include the following line:
>
> Redirect permanent oldpage.html
> http://yourserver.com/newpage.php
>
> This will tell Apache that oldpage.html is no longer
> valid and
> automatically redirect visitors to the new page.
> Note: This only
> works if your webserver is Apache, other webservers
> probably have this
> option elsewhere. See also:
>
http://httpd.apache.org/docs/mod/mod_alias.html#redirect
>
> ******** 2) Force PHP parsing of your old file
> To do this, create/modify a .htaccess file in the
> directory where your old
> page is and include the following lines:
>
> <Location oldpage.htm>
> ForceType application/x-httpd-php
> </Location>
>
> This will force apache to process oldpage.htm as a
> PHP file. See also:
>
http://httpd.apache.org/docs/mod/mod_mime.html#forcetype
>
> ******** 3) Force PHP parsing of all .htm files
> This is similar to method 2, but you will need
> access to your httpd.conf
> file. Open it, and look for the line that says:
>
> AddType application/x-httpd-php .php
>
> and then simply add .htm at the end of it:
>
> AddType application/x-httpd-php .php .htm
>
> This will tell Apache to send all .htm files on your
> server through the
> PHP parser. It works, but performance-wise it is not recommended to
> send all files through the PHP parser. See also:
>
http://httpd.apache.org/docs/mod/mod_mime.html#addtype
>
> IMHO, I believe you should try these options in the
> order given, but
> depending on your needs you might go with another
> option.
>
> Good luck with that...
>
> Joerg.
>
> PS: And yes, [? should be <?php and ?] should be ?>
>
> -----Original Message-----
> From: Mike Young [mailto:mikeyoung80@yahoo.com]
> Sent: Wednesday, January 08, 2003 6:13 PM
> To: php-install@lists.php.net
> Subject: [PHP-INST] Need help putting a small pice
> of code on an html page
>
>
> On Fri, Jan 03, 2003 at 11:33:45AM -0800, Mike Young
> wrote:
> >
> > Hi,
> >
> > I'm new to the list and pretty new to php so
> please
> > forgive my ignorance.
> >
> > I came across a piece of php code to redirect
> foreign
> > countries to a page translated into their language
> and
> > I wish to put it on an html page. The page has a
> > ..htm extension and I don't want to change it to a
> .php
> > extension because it's in search engines, traffic
> > trades etc. But when I put it on my htm page the
> code
> > shows. I've pasted the code below, just as I found
> it.
> >
> > My question: How can I make this work, after
> editing,
> > on a page with an htm extension without having to
> > change it to a php extension?
> > Also , i notice it begins [? and ends ?]. Should
> that
> > be <? and ?> instead. I assume it should go in the
> > body of the page?
> >
> > As I said I'm pretty new to php so forgive the
> > ignorance. Any help would be very much
> appreciated.
> > Thanks,
> > Mike
> >
> >
> > here it is:
> >
> > PHP FILTERING CODE
>
> [?
> $user_lan = $HTTP_ACCEPT_LANGUAGE;
>
> if($user_lan=='de') {
> ## German
> $redir_url =
> "http://www.germanlanguagepageurl.com";
>
> } elseif($user_lan=='fr') {
> ## French
> $redir_url =
> "http://www.frenchlanguagepageurl.com";
>
> } elseif($user_lan=='it') {
> ## Italian
> $redir_url =
> "http://www.italianlanguagepageurl.com";
>
>
> } elseif($user_lan=='es') {
> ## Spain
> $redir_url =
> "http://www.spanishlanguagepageurl.com";
>
>
> ## US traffic or Rest of world not defined above
> } else {
> $redir_url = "http://www.yourmainpageurl.com";
>
> }
>
> header("Location: $redir_url");
> exit;
>
> ?]
>
>
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
>
> --
> PHP Install Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> PHP Install Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--
PHP Install Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php