homepage Welcome to WebmasterWorld Guest from 54.167.138.53
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Allowing colon : in rewrite rule?
hiccupsheadache




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

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!

 

Dideved




msg:4573296
 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 https://issues.apache.org/bugzilla/show_bug.cgi?id=41441 for more into.

hiccupsheadache




msg:4573357
 10:37 pm on May 12, 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!

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

lucy24




msg:4573365
 11:25 pm on May 12, 2013 (gmt 0)

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.

Dideved




msg:4573385
 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved