Page 1 of 1

Shortcode...URL. /contact-us/

Posted: Tue Jun 02, 2009 4:25 pm
by simonmlewis
Hi

This seems a common thing to do, but I don't know how.......

How do you setup script so a page can be viewed through a short url.
For example, http://www.mywebpage.co.uk/conveyancing-quote/

Can a script be made so that /conveyancing-quote/ is the shorturl for
http://www.mywebpage.co.uk/index.php?page=45&s=332 ??

I know how to do a redirector in HTML, but this is different.

Simon

Re: Shortcode...URL. /contact-us/

Posted: Tue Jun 02, 2009 5:04 pm
by requinix
There's a rule on the server that says "if this thing can't be found, go here". It happens internally so you (the user) don't see that you're being redirected to index.php?...

If you're using Apache with mod_rewrite:

Code: Select all

RewriteEngine On
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?shortcut=$0
Your index.php has two purposes now: one is to serve the front page to the website, the other is to handle shortcuts. (You could have a PHP file specifically handle shortcuts if you wanted.)

index.php can look at $_GET["shortcut"] to see if it's supposed to serve something. It gets the "conveyancing-quote" and decides what to do from there.

Re: Shortcode...URL. /contact-us/

Posted: Wed Jun 03, 2009 2:54 am
by simonmlewis
Thank you.

I will look up and research $_GET["shortcut"] to see how to make it all happen, as it looks like a standard PHP method.

Regards
Simon

Re: Shortcode...URL. /contact-us/

Posted: Wed Jun 03, 2009 4:26 am
by simonmlewis
Hi - this doesn't seem as straight forward as I thought, and there isn't all that much about it on the web.

ie. I would have thought there's be a /page/ type script somewhere, with the url it directs to, and an include or something in the index.php file that does it all.

Not as simple as that??