Welcome to WebmasterWorld Guest from 54.166.178.177

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Allowing colon : in rewrite rule?

     
11:53 am on May 12, 2013 (gmt 0)

5+ Year Member



Hi guys,

for some reason - I cannot get my htaccess rewrite to allow colons : - in my urls...

I have this:


# Stop if it's a request to an existing file.
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]

# Redirect all requests to the index page

RewriteRule (.*) page.php [NE,L,QSA]



I thought (.*) would allow everything.

This works:

.com/1234fsjsjskk/

but this wont:

.com/1234fsjsjskk:56/


I'm using php to split the complete string to how I need it.


$tokens = preg_split('#/#', $_SERVER['REQUEST_URI'], -1, PREG_SPLIT_NO_EMPTY);


Thanks so much for any help!
2:32 pm on May 12, 2013 (gmt 0)



Turns out this has nothing to do with your rewrite rules. Apache for Windows intentionally disallows colons in the first path segment. It's meant to avoid security issues, since the underlying filesystem also uses colons.

See [issues.apache.org...] for more into.
10:37 pm on May 12, 2013 (gmt 0)

5+ Year Member



Thanks Dideved - I don't know how you found that out -- I spent ages trying/changing the htaccess file trying to get it to work!

It works fine when I move my code to a Linux server :-)
11:25 pm on May 12, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



It works fine when I move my code to a Linux server

Uh-oh. There are situations when you can safely ignore a particular platform or a particular browser ... but if you've got an URL that only works on some servers, you should think seriously about changing the URL to something more interoperable. You can't go wrong with alphanumerics.
12:51 am on May 13, 2013 (gmt 0)



Thanks Dideved - I don't know how you found that out -- I spent ages trying/changing the htaccess file trying to get it to work!


I started off just copy-pasting your htaccess and tried a URL with a colon. Got a "Forbidden" response, which is unusual. Checked the error.log and saw the message "The given path is misformatted or contained invalid characters." Popped that error message into Google, and found the bug report I posted above.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month