newhip Posted September 28, 2013 Share Posted September 28, 2013 Ok I've seen urls like www.domain.com/title-of-page-blah-blah and i understand how to make the url with the dash. My question is how to I set that on the index page? I know how to do that after a set a $GLOBALS['q']['view'] and get the page like www.domain.com/view/title-of-page-blah-blah but not without the "view" or wtv i would set it to. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/ Share on other sites More sharing options...
Irate Posted September 28, 2013 Share Posted September 28, 2013 Check the mod_rewrite.so module for Apache and their .htaccess and httpd.conf files for URL rewriting. Also, using global is more likely a sign of doing it wrong than right. Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451570 Share on other sites More sharing options...
Ch0cu3r Posted September 28, 2013 Share Posted September 28, 2013 (edited) Your question doesn't make sense. Your php app is most probably using mod_rewrite. For example the url domain.com/view/title-of-page-blah-blah is actually being mapped to the following url domain.com/page.php?q=view&title=title-of-page-blah-blah You'd access view and title using $_GET['q] and $_GET['title] variable. Not $GLOBALS. Edited September 28, 2013 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451571 Share on other sites More sharing options...
KevinM1 Posted September 28, 2013 Share Posted September 28, 2013 Forget you know anything about $GLOBALS or the 'global' keyword. Using them is the path to madness, then death. Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451585 Share on other sites More sharing options...
Solution vinny42 Posted September 28, 2013 Solution Share Posted September 28, 2013 What I do is rewrite every URL that is not an images/folder etc to index.php and use $_SERVER to look at the URL and decide how to route the request. I've seen may people get into very deep doodoo trying to create a new rewrite for every different URL structure they have, especially when the original request also contained a parameter that you use in the rewrites. Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451587 Share on other sites More sharing options...
newhip Posted September 29, 2013 Author Share Posted September 29, 2013 I don't know much about "$_SERVER" but after some quick research it seams like that is exactly what i'm trying to do. Thanks a lot guys! Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451642 Share on other sites More sharing options...
newhip Posted September 30, 2013 Author Share Posted September 30, 2013 Ok i got a new problem regarding this same topic... I got everything working and I'm able to read off the the url with $_SERVER but now it's looking for a file on my server. How do i make it not look for a file and just know that it's actually just data that i've injected into the url? Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451801 Share on other sites More sharing options...
Ch0cu3r Posted September 30, 2013 Share Posted September 30, 2013 I got everything working and I'm able to read off the the url with $_SERVER but now it's looking for a file on my server. What is looking for a file? How do i make it not look for a file and just know that it's actually just data that i've injected into the url? You need to apply logic for your script for to do that. Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451816 Share on other sites More sharing options...
newhip Posted September 30, 2013 Author Share Posted September 30, 2013 k got it Quote Link to comment https://forums.phpfreaks.com/topic/282505-globals/#findComment-1451908 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.