-1

I want to get a PHP script to run when I go to a certain folder in my website, but not have it display in the URL.

I want /number/number.php to run whenever the user visits /number/

Do I need to use the .htaccess file to do this?

ashjack
  • 43
  • 5
  • 1
    Possible duplicate of [how to make default page home.php instead of index.html and index.php](http://stackoverflow.com/questions/15779198/how-to-make-default-page-home-php-instead-of-index-html-and-index-php) – Croises Nov 12 '16 at 13:08
  • 3
    Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – thatguy Nov 12 '16 at 14:48

2 Answers2

4

You can try to create an index.php file on this folder and use a include statement to include number.php. As far as I now, everytime you type a folder at a URL, the server search for an index file to run and the index.php is not included at the url.

2

If you want a script to run without having the user visit that page.. you can simply include the file in another file.. example, you can create an index.php in folder /number/ which contains the code:

<?php
include("./numbers.php"); /* the './' means, it refers to the same folder */
?>