?
Solved

calling php without having the page extension = .php

Posted on 2003-11-28
4
Medium Priority
?
252 Views
Last Modified: 2006-11-17
Dear All,

I have a html page which would like to include a php script to it, the script is to check the current page URL and if the address is a "specific" address, the page would be redirect to a blank page.

The script is tested and ok, but I don't know how can I add it to the html page..as I don't want to change the page extension from html to php.

I have tried to use an image <img src="myscript.php" width="0" height="0"> but it seems that the script doesn't work.

I have also tried to use js instead..but as I can only include the script in onLoad section, the page may be loaded before the script takes action.

please advise on how can I do that..thanks!
0
Comment
Question by:ping1234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
vincevincevince earned 200 total points
ID: 9837038
make a file called ".htaccess" (apache only)
put it in the root of the folder
put in the file just the following line:
AddType application/x-httpd-php .php .php3 .html .htm

this will instruct php to parse the htm or html pages without a change in extension
then just put in your html page <?php include("myscript.php"; ?>
0
 

Expert Comment

by:esther_6694
ID: 9840758
Thanks! it works!
0
 
LVL 1

Expert Comment

by:vincevincevince
ID: 9841831
I'm glad to hear that.
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question