Welcome Guest, Not a member yet? Register   Sign In
hyphenated third level domain name problem
#1

[eluser]Volder[/eluser]
Hello.

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 http://username.mysite.com
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 http://username.mysite.com
and it is displayed the same way as the request http://mysite.com/user/index/username

But when I put http://username-username.mysite.com
it gives me an error:

Code:
The URI you submitted has disallowed characters.

But when I put the same user as http://mysite.com/user/index/username-username
it is working fine and is displaying the page for the user called username_username.

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

and here is my .htaccess rules:

Code:
RewriteBase /
RewriteEngine on

#this rule will transfor all personal blogs
#from http://author.mysite.com/blog/DDD... to http://mysite.com/user/index/author/blog/DDD...
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?
tnx

PS
one more additional info to this problem.
When I enable rewrite logs and load the page like http://username-username.mysite.com the logs are empty, so it seems that the rewrite is not even reached - which is very strange for me.
#2

[eluser]jtkendall[/eluser]
Try moving the hyphen to the end of your allowed characters string. It's likely seeing it as a range between \ and а
#3

[eluser]Volder[/eluser]
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 http://mysite.com/user/index/username-username 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.
#4

[eluser]Volder[/eluser]
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 ((




Theme © iAndrew 2016 - Forum software by © MyBB