codeIgniter不能在主域到子文件夹之后工作

我从HostGator购买新的多域共享托pipe计划。

www.example.com是我的主域(根域)

public_html/ example .htaccess 

我在public_html / .htaccess中使用此代码更改我的主域名

 RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com$ RewriteCond %{REQUEST_URI} !example/ RewriteRule (.*) /example/$1 [L] 

现在public_html / example是我的新主域

我在示例文件夹中设置CodeIgniter项目,它为www.example.com/工作,但不工作www.example.com/index.php/about它是返回No input file specified.

这是我在public_html/example/.htaccess CodeIgniter public_html/example/.htaccess

 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule> 

但不适用于www.example.com/index.php/about

这似乎是问题 – 这看起来不像你应该请求的URL。 (为什么我要求澄清在评论。)

从你发布的代码看起来你应该请求一个forms为www.example.com/about的URL(没有index.php – 我认为这会更好)。 然后在内部重写为/example/about ,然后将其重写为/example/index.php/about ,然后由CodeIgniter进行路由。

但是,如果您按照您的build议请求了www.example.com/index.php/about ,那么它最终会被重写为/example/index.php/index.php/about哪个CodeIgniter将无法路由。


 RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com$ 

除此之外:你应该在正则expression式中反斜杠,否则它匹配任何字符。 但是,这可以写在一行上:

 RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] 

尽pipe你最好在代码中使用外部redirect来对域(www或非www)进行canonical化,否则Google可能会将其视为重复。