我想在' mydomain.com '上安装codeigniter,托管(共享)呈现下一种结构:
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强制/应用重写条件?
答案 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]