CodeIgniter Forums
hyphenated third level domain name problem - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: hyphenated third level domain name problem (/showthread.php?tid=20094)

hyphenated third level domain name problem - El Forum - 06-28-2009


I'm facing a problem which I still can not understand the reason for.
Maybe someone here could help me.

I have a logic on the site when user page looks like
So username is a third level domain.
Username may contain alphanumeric or underscore.
For example, username_username.

For addressing to such a user page I replace "_" with "-" as hyphen is only allowed to be used in domain names, but not underscore.

Then I have a controller called "user".
And all such requests (with 3rd level domains) are readdressed in .htaccess to user/index/username

This is working fine when username does not contain underscores.

So I input
and it is displayed the same way as the request

But when I put
it gives me an error:

The URI you submitted has disallowed characters.

But when I put the same user as
it is working fine and is displaying the page for the user called username_username.

I have included hyphen in the permitted chars:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-а-я,+';

and here is my .htaccess rules:

RewriteBase /
RewriteEngine on

#this rule will transfor all personal blogs
#from to
RewriteCond %{HTTP_HOST} ^((.*)\.)mysite\.com$
RewriteCond $1 !^user
RewriteCond $1 !^index.php/user
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule ^(.*) user/index/%2/$1 [L]

#this rule will add index.php at the beginning of any rule except mentioned in the condition
RewriteCond $1 !^(index\.php|img|favicon\.ico|debug_images|images|robots\.txt|captcha|css|js|phpmyadmin|user_guide|stats|techpause\.html)
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteRule ([^-]*)-([^-]*)-?([^-]*)-?([^-]*)-?([^-]*) $1_$2_$3_$4_$5 [L]

RewriteRule ^(.*?)__+(.*) $1$2 [L]

Does anyone have any ideas, because I'm really stuck with this?

one more additional info to this problem.
When I enable rewrite logs and load the page like the logs are empty, so it seems that the rewrite is not even reached - which is very strange for me.

hyphenated third level domain name problem - El Forum - 06-28-2009

Try moving the hyphen to the end of your allowed characters string. It's likely seeing it as a range between \ and а

hyphenated third level domain name problem - El Forum - 06-28-2009

thanks for the reply.

I have tried to move hyphen to the end of the allowed characters pattern before - and it didn't help.

Moreover - I'm sure hyphen is seen as allowed character in the URL as is working fine.

Actually, even though I have not found a solution on my local server, after the upload to production - it is working fine there.

I think the problem is in different Apache parametrization which I don't know about.
On the production server I use $config['uri_protocol'] = "ORIG_PATH_INFO"

On the local server I have tried all the 5 possiblities - but without any success.

So as I don't have problems in production server - it is not very critical for me, but I would like to find the reason anyway, because now I still don't understand such a behavior.

hyphenated third level domain name problem - El Forum - 06-28-2009

very strange

I have relaunched the browsers (chrome, safari, opera, IE).

Now I get 404 page instead of the "not allowed character in the URL"

But this 404 page is not appearing in CI logs.

So now I'm confused even more ((