arunpatal Posted February 18, 2014 Share Posted February 18, 2014 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..... Quote Link to comment https://forums.phpfreaks.com/topic/286280-header-url/ Share on other sites More sharing options...
Rifts Posted February 18, 2014 Share Posted February 18, 2014 my advice would be to actually take 10 mins and learn how to code in php. what you are trying to do can be done like this $sentValue = $_GET['x']; this will get the 'value' Quote Link to comment https://forums.phpfreaks.com/topic/286280-header-url/#findComment-1469337 Share on other sites More sharing options...
arunpatal Posted February 18, 2014 Author Share Posted February 18, 2014 (edited) 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 Edited February 18, 2014 by arunpatal Quote Link to comment https://forums.phpfreaks.com/topic/286280-header-url/#findComment-1469339 Share on other sites More sharing options...
Ch0cu3r Posted February 18, 2014 Share Posted February 18, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/286280-header-url/#findComment-1469384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.