Get Referer URL and FOLDER name in PHP -


I have several folders on my domain, each folder has an index.php file that checks to see that Whether the database connection passes or fails, if it fails, the top level file (outside of all folders) is called offline.php to the page. This part works great if DB is offline then I'm using to redirection the original format:

  if (! $ Dbconnect) {header ("Location: https: // www .test.com / offline.php "); }  

Then, offline. Within Php page, I need to see which folder user is offline. Bring to Php page and display a unique message for the user - based folder that has brought them to the offline php page.

For example:

test.com/test1/index.php redirects to .php offline, the message will say 'test1 brought you to this page'

test.com/test2/index.php redirect to .php offline, the message will say 'test2 brought you to this page'.

Browsers in multiple, I have used the following code, which is always in 'unknown uri':

  $ url = 'https: //' $ _SERVER ['HTTP_REFERER']; If (SRPO ($ url, 'test')! == incorrect) {echo 'test'; } Otherwise (strops ($ url, 'test1')! == incorrect) {echo 'test1'; } Otherwise (strops ($ url, 'test2')! == incorrect) {echo 'test2'; } And {echo 'unknown yuri'; }  

Suggestions?

Edit Because of the unreliable nature of HTTP_REFERER, I have decided that all the positions will be placed inside the index. Forget about php page and offline.php page A lot of people thank you who offered suggestions!

Why do you use redirects? They are heavy on the server, slow and just plain old unnecessary. Use a switch statement and have 1 control page instead of multiple folders and pages.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -