![](/img/trans.png)
[英]htaccess redirect domain.com to www.domain.com except of staging.domain.com for multiple domains
[英]Yii:: redirect www.domain.com/index.php to www.domain.com without using htaccess
我有一個需要重定向的地方
domain.com/index.php, www.domain.com/index.php & www.domain.com/index/ to www.domain.com
我的應用程序未使用.htaccess文件。 它只能用php完成。
我想沒有.htaccess文件沒有解決方案,所以建立一個
在yii配置中的component上設置main.php:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
),
成為
LoadModule rewrite_module模塊/mod_rewrite.so
然后轉到.htaccess文件,並嘗試將其修改為:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
如果上述方法不起作用,請嘗試以下操作:
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
將.htaccess文件移動到index.php所在的根目錄。
www-protected-index.php-.htaccess
重新啟動服務器,然后一切正常
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.