I want to install codeigniter on ' mydomain.com ', hosting (shared) presents next kind of structure:
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 '?
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]
My htaccess that worked for me in host
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.