1

I am on a website. the URL reads something like https://somesite.com/serve

I need to tell the name of the page that is serving me.

Like index.html, index.htm, etc...

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Ted
  • 3,805
  • 14
  • 56
  • 98
  • Like "page.php"? Like "site.jsp"? Like "website.wsgi"? – Ignacio Vazquez-Abrams Apr 17 '12 at 23:01
  • In PHP or JavaScript? You tagged both. – Quentin Apr 17 '12 at 23:03
  • Try and trigger a server error like with a malformed HTTP/1.0 request perhaps it will print the server version or use a tool like this net-square.com/httprint/, If the server is running apache then you can almost guarantee its a php driven site with mod_rewrite, also by looking at the source of a script you can pick out the specific script from similarity's, like with wp. Tho like with most things its almost impossible to be sure unless the info is made public – Lawrence Cherone Apr 17 '12 at 23:17

6 Answers6

4

It is fundamentally impossible for you find that out.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

You want to know the file that is being served. Well probably you are facing url rewrite with htaccess or other techniques. To tell which file it is probably is impossible if only you manage to get framework (if it is framework) in which the page is made. Then you can read in documentation which is the file to which the requests are aimed. Most frameworks will have one or several of these files. For example codeignighter will have only index.php, while symfony 2 will have app.php and app_dev.php (and others if you want different environments). But normaly you cant know which file serves your request if url rewrite is made.


As mentioned @Dale you cant also beleave what urls say. Because you cant stick some extension at the end for it to look as file. Sometimes you can notice .php or more often .html / .htm at the end.

Jānis Gruzis
  • 905
  • 1
  • 10
  • 25
0

I'm not entirely sure what you mean. But I'm certain you can find it with $_SERVER (Documentation can be found here)

Good luck

Mads
  • 724
  • 3
  • 10
0

If you just trying to find out the page name then you can do this:

<?php
$currentFile = $_SERVER["PHP_SELF"];
$parts = explode('/', $currentFile);
echo $parts[count($parts) - 1];
?>
user1048676
  • 9,756
  • 26
  • 83
  • 120
0

probably then you have a .htaccess with rewrite rules which looks something like:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Else you probably would have query string instead which probably looked something like:

index.php?c=products&m=view&id=345
Alfred
  • 60,935
  • 33
  • 147
  • 186
0

(Assuming server supports .htaccess, mod_rewrite, mod_headers)

Temporarily use .htaccess RewriteRule to reveal all or matching filenames in a header.

Example tags all php file headers with filename:

<IfModule mod_rewrite.c>
RewriteEngine on
    <IfModule mod_headers.c>
        RewriteRule .*\.php$ - [E=FILENAME:$0]
        <FilesMatch ".php$">
           Header set MY-COOL-FILENAME "filename=%{FILENAME}e"
        </FilesMatch>
    </IfModule>
</IfModule>

Links

Setting a filename inside the header with htaccess

View HTTP headers in Google Chrome?

hellork
  • 324
  • 2
  • 8