Page 1 of 1

Using colons in a URL

Posted: Mon Mar 20, 2006 10:14 am
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 ++

Posted: Mon Mar 20, 2006 10:34 am
by John Cartwright
Are you currently using mod_rewrite? If so, please post the contents of your htaccess

Posted: Mon Mar 20, 2006 10:40 am
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.

Posted: Mon Mar 20, 2006 11:46 am
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. :)

Posted: Mon Mar 20, 2006 12:01 pm
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]