Yii Framework Forum: Need help with mod_rewrite rule - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need help with mod_rewrite rule Rate Topic: -----

#1 User is offline   zyphers 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 04-March 10

Posted 22 October 2010 - 05:45 AM

Hi guy,

I have problems with setting Yii in virtual host.
I can't go to any link from the home page. In error log it said
Since I can't modify the rule of the host I can only fix it in .htaccess.
Request exceeded the limit of 10 internal redirects due to probable configuration error

Here are my config file for virtual host in apache2.conf
<VirtualHost *:80>
	UseCanonicalName Off
	VirtualDocumentRoot /data/www/vhosts/%0/htdocs/
	CustomLog /data/logs/wildcard-access_log combined
	ErrorLog /data/logs/wildcard-error_log
	<Directory /data/www/vhosts/>
		AllowOverride All
		Options -Indexes -FollowSymLinks -MultiViews
		Deny from all
		Allow from 192.168.0 192.168.1 192.168.2 192.168.3
		AuthType Basic
		AuthName "Top Secret"
		AuthUserFile /data/www/vhosts/.htpasswd
		require valid-user
		Satisfy any
	</Directory>
</VirtualHost>


And here is my .htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php


Yes it's default. It is located in :-
/data/www/vhosts/www.example.com/htdocs
(www.example.com is for example)

My mian.php in config is.. (show only URL part)
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array(
                  'somerule' => 'something'
            ),
        )


Do anyone have anyone ideas?

Thanks in advance,
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,359
  • Joined: 12-October 09
  • Location:Croatia

Posted 22 October 2010 - 06:03 AM

Just googled this error and found this link - http://www.webmaster...orum92/5628.htm
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   zyphers 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 04-March 10

Posted 22 October 2010 - 06:29 AM

Thanks,

From that I investigated more so I found...
The rewrite loops from ../htdocs/index.php to ../htdocs/index.php so that's why it said Request exceeded the limit of 10 internal redirects due to probable configuration error

That's what I know about it but how to solve still a myth :(

The only hope is mod_rewrite configuration... I'm not expert for this kind of things.
0

#4 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 22 October 2010 - 06:37 AM

View Postzyphers, on 22 October 2010 - 05:45 AM, said:

And here is my .htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php


Yes it's default. It is located in :-
/data/www/vhosts/www.example.com/htdocs
(www.example.com is for example)



This rule is not correct. The correct rule is:


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]



0

#5 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 22 October 2010 - 06:45 AM

Oops, sorry, just checked the docs again, your rule is correct. But maybe give my alternative a try.
0

#6 User is offline   zyphers 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 04-March 10

Posted 24 October 2010 - 11:59 PM

Hi Mike,

I've just tried it but unfortunately it didn't work.
Anyway thanks for that if I can try something that means we're close to the solution.
And when I looked at the error log of my server I found this.

[Mon Oct 25 06:40:52 2010] [error] [client 192.168.1.225] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3063): [client 192.168.1.225] r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/products, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /htdocs/index.php/product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] core.c(3069): [client 192.168.1.225] redirected from r->uri = /product, referer: http://www.myexample.com/
[Mon Oct 25 06:40:52 2010] [debug] mod_deflate.c(615): [client 192.168.1.225] Zlib: Compressed 604 to 366 : URL /htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/htdocs/index.php/product, referer: http://www.myexample.com/


My Yii app is installed at www.myexample.com.
And I tried to reach www.myexample.com/product.

If anyone has any clues, I'll thank you very much.
0

#7 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 25 October 2010 - 03:37 AM

You did, what i would do, too: Check the logs to see what's happening. My next step would be: Try another server, where it works and compare the output. And maybe increase the log level for mod_rewrite.

Let us know, what you find out.
0

#8 User is offline   OrlŠ°ngur 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 20-January 11
  • Location:Kiev, Ukraine

Posted 20 January 2011 - 03:59 AM

Quote

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]

I modified this rule a bit and that helped :)

RewriteRule ^([^/].*)$ /index.php/$1 [L]

The idea is to add slash in the beginning so that the rule will not match after rewrite completed.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users