Solved

calling php without having the page extension = .php

Posted on 2003-11-28
4
251 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 50 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

688 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