[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

calling php without having the page extension = .php

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
ping1234
Asked:
ping1234
  • 2
1 Solution
 
vincevincevinceCommented:
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
 
esther_6694Commented:
Thanks! it works!
0
 
vincevincevinceCommented:
I'm glad to hear that.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now