yii framework Url: hide index.php

来源:互联网 发布:阿里云 安装包 编辑:程序博客网 时间:2024/05/18 03:51

Maybe it looks simple, but some time ago I need some time to find a solution of this case. I finally got it, and I want to share that I also experienced such cases. So that it can make reference.

Neither let us do the steps:

  • Make sure that the hosting / your pc mod_rewrite  module  is active. if not actively try to activate in a way, open the httpd.conf file. You can check this in the phpinfo.php to find out.

change this setting :

#LoadModule rewrite_module modules/mod_rewrite.so

to be

LoadModule rewrite_module modules/mod_rewrite.so
  • then go to .htaccess file, and try to modify to be:
RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

if above does not work try with this:

RewriteEngine on# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# otherwise forward it to index.phpRewriteRule . index.php
  • move .htaccess file to root directory, where is index.php thare.
www - protected - index.php - .htaccess
  • Set main.php in your yii configuration, at component :
'urlManager'=>array(    'urlFormat'=>'path',    'showScriptName'=>false,     'caseSensitive'=>false,        ),
  • so.., good luck

For reference material I managed to do in my personal website (check  my profile).

NB: This for hide index.php

Total 12 comments

#9725report it
  • 0
  • 0
thiromi at 2012/09/06 06:50pm
One more thing...

Also, if you're on a virtual directory (e.g. using

Alias /dir/ "/dir/"

on your apache configuration) you MUST use a

RewriteBase /dir/

statement on your .htaccess file, other than the rewrite won't work again.

 

原创粉丝点击