【问题标题】:Redirect domain in .htaccess to yii application将 .htaccess 中的域重定向到 yii 应用程序
【发布时间】:2014-08-08 09:13:38
【问题描述】:

我需要在服务器上的根目录中的 .htaccess 中重定向域。 我的 .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !/yii/projectName/
RewriteRule ^(.*)$ /yii/projectName/$1 [L]

主页应用程序可以工作,但 url manager 不工作,它总是重定向到主页。

我的网址管理器:

'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
...
),

感谢您的帮助

【问题讨论】:

  • 这个问题似乎跑题了,因为它是关于网站管理员的。

标签: .htaccess redirect yii


【解决方案1】:

试试这个:

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

一年前我在这里找到了这个替代解决方案:http://www.yiiframework.com/wiki/214/url-hide-index-php/

编辑

网址管理器设置似乎没问题,但请务必在您的自定义网址规则之后添加这些规则:

'rules'=>array(

            // ... add you custom url rules here, if there are any

            // Home page
            '/' => 'info/index', // edit this to your home page controller/action

            // Default patterns for any other controller/actions.
            // These are checked last, if there were no applicable custom rules for a specific URL
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:\w+>/<action:\w+>/*' => '<controller>/<action>'
),

【讨论】:

  • 没有人尝试在 .htaccess 根服务器中重定向域在 yii 应用程序上?
猜你喜欢
  • 1970-01-01
  • 2011-08-27
  • 1970-01-01
  • 2014-08-19
  • 2013-02-20
  • 2023-03-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多