doutao4938 2016-04-14 08:28
浏览 56

模块的Yii url经理没有工作给404

I have created the module named enquiry in my project .

If I am running below line http://enqphp.intermesh.net/index.php?r=enquiry/Enquiryser/index/ then this URL is working perfectly. But I want it to be short like http://enqphp.intermesh.net/enquiry

For this, I have done some modifications in my main.php file in URL manager section:

return array(
   'caseSensitive' => true,
       'urlSuffix' => '/',
       'showScriptName' => false,
      'urlFormat' => 'path',
   'rules' =>
    array(
    '/' => array('site/index'),

    /* my files starting from here */
    '<modules>/<controller:\w+>/<id:\d+>' => '<modules>/<controller>/view', '<modules>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<modules>/<controller>/<action>',
    '<modules>/<controller:\w+>/<action:\w+>/*' => '<modules>/<controller>/<action>',
    '/enquiry/'=>'enquiry/Enquiryser/index',
    ),
)

But it's not working and throwing 404 page not found . Can anyone help me that what I am missing ?

  • 写回答

2条回答 默认 最新

  • doudg60800 2016-04-14 10:42
    关注

    What web server do you use? Nginx, Apache?

    Apache To hide index.php in your URLs you can add mod_rewrite instructions to the .htaccess file in your document root or to the virtual host configuration:

    RewriteEngine on
    
    # prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)
    RedirectMatch 403 /\..*$
    # 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
    

    Nginx You must have follwoing config for you server

    location / {
            index  index.html index.php;
            try_files $uri $uri/ /index.php?$args;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了