[英]codeigniter .htaccess in shared hosting (mochahost)
I want to install codeigniter on ' mydomain.com ', hosting (shared) presents next kind of structure: 我想在' mydomain.com '上安装codeigniter,托管(共享)呈现下一种结构:
index.php (modified): index.php (修改):
<?php
...
$system_path = 'codeigniter/system';
$application_folder = 'codeigniter/application';
...
.htaccess (default): .htaccess (默认):
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 '? 如果url有' mydomain.com ',我如何修改.htaccess强制/应用重写条件?
To affect only mydomain.com
, add a RewriteCond
that matches it in %{HTTP_HOST}
before the first RewriteCond
. 只影响
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]
If you also need to match www.mydomain.com
, make the condition as: 如果您还需要匹配
www.mydomain.com
,请将条件设置为:
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain.com$ [NC]
My htaccess that worked for me in host 我的htaccess对我来说很有用
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.