Yii :: Problem Using Showscriptname = False And Url Manager

I am currently having a problem using the URL manager and / or apache mod_rewrite or maybe something else.

If showScriptName is set to false, referrals to addresses such as domain.com/login, domain.com/logout, domain.com/site/login behave the same. It just shows the main site / index, as if I were supposed to go to domain.com/eeofjew9j8jfdedfmewf (jibberish).

Perhaps this is a problem with the settings of Yii? Here are those (sorry for the sloppiness):

'components'=>array( 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 'login'=>'site/login', 'logout'=>'site/logout', 'register'=>'users/register' ), ,... 

This is how I set my .htaccess setting to www root directory:

 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 

I use a VPS server, so I have root access to make any changes necessary for apache. I checked my phpinfo and mod_rewrite is up and running. In my apache configuration, I have for my www directory:

 AllowOverride All Options Indexes FollowSymLinks MultiViews Order allow,deny Allow from all 

I scratch my head on this issue through 3 different hosts (godaddy, dreamhost and lithiumhosting), so I assume this is a problem at my end. Now that I have VPS, I hope that I can finally find out my problem and solve it.

+4
source share
3 answers

First, make sure the server parses the .htaccess file. This is simply done by placing random text in a .htaccess file, e.g.

 CREATE AN ERROR 

If this gives you a server error, the file is parsed. You may need to move the .htaccess file to a directory in order to make it work.

After that, check the operation to make sure that the rewrite module in Apache is enabled. First check phpinfo and find the executable. If not, you may need to remove the comment character (#) before the module.

After the module appears in phpinfo, see if you can do basic correspondence to make sure there are no problems with Apache.

 RewriteEngine on RewriteRule ^ http://google.com/? [L,R] 

If this does not work, try adding

 Options +SymLinksIfOwnerMatch 

to file

After Apache does this now, it depends on yii. This code:

 RewriteEngine On RewriteBase /mybasedirectory RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA] 

adds the rewrite base option, which may be required if you do not have files in the root of the document, such as htdocs

finally, if this does not solve the problem, then restrict your rule to a simple rule such as

  'contact'=>'site/contact', 

and see, at least, redirected to where you think. Of course, you may need to check the basic .htaccess rules again to make sure that overide is enabled and there is no invalid .htaccess in the subdirectory. Hope this helps. Finally, I got a job.

+2
source

What happens if you delete these lines!

 enter code here # otherwise forward it to index.php RewriteRule . index.php 
+1
source

if you add this code see if it works

 '<action:(login|logout|register|contact)>' => 'site/<action>', 
+1
source

All Articles