yii framework Url: hide index.php

简介: Maybe it looks simple, but some time ago I need some time to find a solution of this case.

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 On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

if above does not work try with this:

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

  • 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

#9725 report it
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.

 

目录
相关文章
|
小程序 前端开发 PHP
PHP实现生成小程序二维码带参数进入指定页面、小程序URL scheme实现携带数据跳转小程序
PHP实现生成小程序二维码带参数进入指定页面、小程序URL scheme实现携带数据跳转小程序
209 0
|
4月前
|
PHP
php 根据url生成图片并保存
php 根据url生成图片并保存
83 0
|
存储 JSON PHP
在 PHP 中从 URL 获取 JSON 对象
在 PHP 中从 URL 获取 JSON 对象
147 0
|
JSON 前端开发 安全
ajax中实现访问url已阅即焚的解决方案(url动态参数、变量加密、常量不变、php加密解密、API访问验证方式)
ajax中实现访问url已阅即焚的解决方案(url动态参数、变量加密、常量不变、php加密解密、API访问验证方式)
271 0
|
JSON 安全 关系型数据库
php传递url参数加密验证的解决方案(加密解密、安全验证过滤)
php传递url参数加密验证的解决方案(加密解密、安全验证过滤)
392 0
|
前端开发 JavaScript 关系型数据库
宝塔设置PHP定时任务实战记录(定时任务、ajax异步刷新API、shell脚本、访问url)
宝塔设置PHP定时任务实战记录(定时任务、ajax异步刷新API、shell脚本、访问url)
710 0
|
PHP 计算机视觉
php利用百度人脸识别实现人脸融合的解决方案(1)image_type为URL类型
php利用百度人脸识别实现人脸融合的解决方案(1)image_type为URL类型
101 0
|
PHP 开发工具 计算机视觉
PHP SDK百度人脸识别遇见的坑,BASE64识别程度高但加载慢;URL加载快,但总image download fail
PHP SDK百度人脸识别遇见的坑,BASE64识别程度高但加载慢;URL加载快,但总image download fail
116 0
|
PHP
PHP函数获取完整的URL
PHP函数获取完整的URL
65 0