1

I'm currently designing a small intranet for our company.

For now I'm using these links at the navigation:

<a href="./">Home</a>
<a href="./?c=phone">Phone</a>
<a href="./?c=xy">XY</a>

The page-URL looks like this: y.com/?c=phone
I want it to be shorter, e.g. without the c=

My idea was to work with true/false.
So, I won't check the variable c for its value, but I would check if e.g. phone == true.

But how can I implement this?

  • You can use `if(isset($_GET['phone'])` for checking if there is a parameter `phone` in your url? – mario.van.zadel Oct 13 '15 at 12:08
  • Is this running on apache or IIS? You want `/phone` to to load `index.php?c=phone`, but not expose that to user, right? If so look at rewriting URLs. – user3783243 Oct 13 '15 at 12:09
  • First off, none of your examples have query strings (there's no `?`). Second, it's not clear what you're aiming for here. Are you trying to make, say, `y.com/phone`? – Machavity Oct 13 '15 at 12:14
  • mapek: Possible way, thank you! user3783243 - Thanks for that approach, I'll take a deeper look at this! Machavity - Thanks, I've edited my post. Nah, my goal is y.com/?phone which should be possible with true/or false if I'm not mistaken. – Christian Hennig Oct 13 '15 at 12:43

1 Answers1

1

this is the simplest way I can think of:

if(isset($_GET['phone'])){
    //here is your page phone
}

now you can access this page via y.com?phone

Kanti
  • 627
  • 4
  • 18
  • This worked for me, thank you very much, even though I don't think that this is the most elegant way. – Christian Hennig Oct 13 '15 at 12:50
  • something like this could help you: http://stackoverflow.com/questions/12538466/htaccess-friendly-url or this: http://stackoverflow.com/questions/28168375/how-to-write-htaccess-rewrite-rule-for-seo-friendly-url – Kanti Oct 13 '15 at 12:56