Jump to content

HEADER URL


arunpatal

Recommended Posts

I want to do somthing if i have url like domain/index.php or domain/index.php?x=value

if ($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] == $_SERVER['SERVER_NAME'] . "/index.php"){


execute some code..


}
The code above work fine but when index page changes to index.php?x=value then the code doesn't execute.....
Link to comment
https://forums.phpfreaks.com/topic/286280-header-url/
Share on other sites

Sorry that i could not clear what i really want.

I want to hide index.php or anything following index.php like index.php?x=value

That it shows only domain name like mywebsite.com

If your server is setup correctly it should serve index.php by default if you go to site.com/ without specifying a file after the domain.

 

But if you're passing a query string to index.php then you cant hide it. Although you could use mod_write, eg

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$    index.php?x=$1 [L]

Will pass anything after site.com to index.php?x=whatever. For example site.com/example will actually call index.php?x=example and ofcourse $_GET['x'] will return example

Link to comment
https://forums.phpfreaks.com/topic/286280-header-url/#findComment-1469384
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.