Is there a way to skip the php filename in the url without using the .htaccess file?
My url:
https://hostname/page.php/maximum/2000/minimum/200
In the page.php
file I am using:
$parameter_array = explode('/',$_SERVER['REQUEST_URI']);
I am using this one $parameter_array
to filter a table. So it works fine. But the url doesn't look good. I need:
https://hostname/page/maximum/2000/minimum/200
To work like
https://hostname/page.php/maximum/2000/minimum/200
Is there a way to do this without using a file htaccess
? NB: I cannot use the file .htaccess
because my client is forcing me not to use the file .htaccess
or .config
. It will be very helpful if possible.
source to share
You can do it one way:
Create a folder "page" where page.php is.
inside the "page" folder
page -> maximum -> 2000 -> minimum -> 200
Inside the folder "200":
create index.php file
inside the index.php file write:
<?php
include "../../../../page.php";
?>
Hope this works. Happy coding !!!
source to share
If you need https: // hostname / page / maximum / 2000 / minimum / 200 to call page.php you will need to use the .htaccess file.
Another option is to use code generation. For example, when you go https: // hostname / page / maximum / 2000 / minimum / 200 apache will look for the default index.php file. This index.php file might just require your page.php.
If your url is dynamic and your directories don't exist then it will be 404 unless you know ahead of time about your url structure to create the correct directories and files.
The latter method is a bit of a hack, and I will try to convince the client that using rewrite rules is the appropriate approach here.
source to share
AFAIK if you don't have access to the server config, probably not without editing .htaccess
.
If you have access to the server settings, you can, for example, set PHP to be interpreted for all files, not just files ending in .PHP.
But if you had access to the server settings, you probably wouldn't be asking here, right;)
One possible hack worth trying
If you can serve the whole application from one file, do it index.php
, if the server is configured correctly, you won't need to include that name in the URL. Then you can access it:
http://example.com/
and if you want subfolders you have to send them as parameters like this:
http://example.com/?here/or-there/somewhere-else`
Can work, huh?;)
source to share
Use $_SERVER[PATH_INFO]
to get the path after the PHP filename .
So this is /folder/file.php/path/info
.
source to share