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

时间:2012-05-20 14:42:30

标签: php .htaccess codeigniter mod-rewrite shared-hosting

我想在' mydomain.com '上安装codeigniter,托管(共享)呈现下一种结构:

  • 的public_html /
    • 404 /
    • _private /
    • _vti_bin /
    • 的cgi-bin /
    • addondomain1.com /
    • addondomain2.com /
      • 应用/
      • 系统/
    • 的index.php
    • 的.htaccess

index.php (已修改):

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

.htaccess (默认):

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

如果仅在网址为“ mydomain.com ”时才能修改.htaccess强制/应用重写条件?

2 个答案:

答案 0 :(得分:2)

要仅影响mydomain.com,请在第一个RewriteCond之前添加%{HTTP_HOST}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]

www.mydomain.com

如果您还需要匹配RewriteCond %{HTTP_HOST} ^(www\.)?mydomain.com$ [NC] ,请将条件设为:

{{1}}

答案 1 :(得分:0)

我的htaccess在主持人身上起作用了

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]