Using colons in a URL

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Using colons in a URL

Post by Gen-ik »

Hi, guys.


I'm designing a wiki-type site at the moment but have run into a problem with a URL format I would like to use. Basically I would like to use colons in the URL but the server keeps throwing out a 403 (forbidden) page.

Is there a way around this using .htaccess?

An example URL would be....

www.somesite.foo/wiki/Discuss:Topic

The URL gets bounced transparently to a single template PHP file (which works fine without the colon)....

www.somesite.foo/wiki_template.php?requ ... cuss:Topic


Any ideas?


Thanks,
Si ++
Last edited by Gen-ik on Mon Mar 20, 2006 10:41 am, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Are you currently using mod_rewrite? If so, please post the contents of your htaccess
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Thanks for the quick reply.

The htaccess code I'm using is very basic at the moment:

Code: Select all

RewriteEngine on
RewriteBase /wiki/

RewriteRule (.*)$ /wiki_template.php?request=$1 [L,QSA]
That obviously lives in the /wiki/ directory.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

I must be having one of those "stooopid" days today.

If I put the following code in a htaccess file in the site's root directory then it all seems to work ok.

Code: Select all

RewriteRule ^wiki/(.+):(.*) wiki_template.php?command=$1&request=$2 [L,QSA]
RewriteRule ^wiki/(.*) wiki_template.php?request=$1 [L,QSA]
URL == /wiki/Discuss:Topic
RESULT == $_SERVER["QUERY_STRING"] = "command=Discuss&request=Topic"

URL == /wiki/Topic
RESULT == $_SERVER["QUERY_STRING"] = "request=Topic"

I can take things from there without any problems. :)
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

This is probably a safer version...

Code: Select all

RewriteEngine on
RewriteBase /

RewriteRule ^wiki/([^:]+):(.*)$ wiki_template.php?command=$1&request=$2 [L,QSA]

RewriteRule ^wiki/(.+)$ wiki_template.php?request=$1 [L,QSA]

RewriteRule ^wiki/?$ wiki/Home [L,R]
Post Reply