1

My URL is:

https://hostname/page.php/maximum/2000/minimum/200

In page.php file I use:

$parameter_array = explode('/',$_SERVER['REQUEST_URI']);

I use this $parameter_array to filter a table. So, it is working fine. But the URL is not looking good. I need:

https://hostname/page/maximum/2000/minimum/200

To work like

https://hostname/page.php/maximum/2000/minimum/200

Is there any way to do it without using htaccess file? N.B: I can not use .htaccess file because my client is forcing me not to use .htaccess or .config file. Will be very helpful if it is possible.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Asif Iqbal
  • 1,132
  • 1
  • 10
  • 23
  • Not sure if you get notified on answer updates, but I came up with one hacky solution, [check it out](http://stackoverflow.com/a/29734613/486332). – nana Apr 19 '15 at 19:27

4 Answers4

3

AFAIK unless you have access to the server configuration, it is not possible without editing .htaccess.

If you do have access to the server settings, you could for example set PHP as the interpreted for all files, not just files ending with .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 your whole app from one file, make it index.php if the server is configured just right you won't have to include that file name in the URL. You can then access it this way:

http://example.com/

and if you want subfolders then you'd send them as parameters like this:

http://example.com/?here/or-there/somewhere-else`

Could work, right? ;)

nana
  • 4,426
  • 1
  • 34
  • 48
  • In the question it is told that:I can not use .htaccess file because my client is forcing me not to use .htaccess or .config file....... Here: .config means server script. – Asif Iqbal Apr 19 '15 at 19:31
2

If you need https://hostname/page/maximum/2000/minimum/200 to call page.php then you'll 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 is going to look for an index.php file by default. That index.php file can then just require your page.php.

If your URL is dynamic and your directories don't exist then it will 404 unless you can know about your URL structure in advance to generate the proper directories and files.

The latter method is a bit hacky and I would attempt to convince the client that using rewrite rules is the appropriate approach here.

iridian
  • 669
  • 5
  • 13
1

Use $_SERVER[PATH_INFO] to get the path after the PHP file name.

So it's /folder/file.php/path/info.

Community
  • 1
  • 1
CodeAngry
  • 12,760
  • 3
  • 50
  • 57
-1

You can do it one way:

Create a folder "page" where there is page.php .

inside "page" folder

page -> maximum -> 2000->minimum - >200

Inside folder "200":

create index.php file

inside index.php file write:

<?php
include "../../../../page.php";
?>

Hopefully it will work. Happy coding!!!

Asif Iqbal
  • 1,132
  • 1
  • 10
  • 23