duanhe7471 2012-05-20 14:42
浏览 30
已采纳

共享主机中的codeigniter .htaccess(mochahost)

I want to install codeigniter on 'mydomain.com', hosting (shared) presents next kind of structure:

  • public_html/
    • 404/
    • _private/
    • _vti_bin/
    • cgi-bin/
    • addondomain1.com/
    • addondomain2.com/
    • codeigniter
      • application/
      • system/
    • index.php
    • .htaccess

index.php (modified):

<?php
...
  $system_path = 'codeigniter/system';
  $application_folder = 'codeigniter/application';
...

.htaccess (default):

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

How can I modify .htaccess to force/apply rewrite condition only when url has 'mydomain.com'?

  • 写回答

2条回答 默认 最新

  • dsxmwin86342 2012-05-20 14:50
    关注

    To affect only mydomain.com, add a RewriteCond that matches it in %{HTTP_HOST} before the first RewriteCond.

    RewriteEngine on
    # Apply rewrite only to mydomain.com
    # Use [NC] for case-insensitive matching
    RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    If you also need to match www.mydomain.com, make the condition as:

    RewriteCond %{HTTP_HOST} ^(www\.)?mydomain.com$ [NC]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 为什么我按照电路图做出的仿真和实物都不能使用
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web