繁体   English   中英

无法从codeigniter网站URL删除index.php?

[英]Can't remove index.php from codeigniter site URL?

我已经阅读了有关删除它的指南,他们告诉我将其添加到我的htdocs根目录中的.htaccess中:

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

但是我的网站目录是这样的:htdocs \\ mywebsite \\

我尝试在htdocs和mywebsite中都添加htaccess文件,但没有结果。 我也尝试将最后一行修改为

RewriteRule ^(.*)$ mywebsite/index.php/$1 [L]

在htdocs和mywebsite目录中。 但是我不知道什么是正确的.htaccess语法或它如何工作,因此我并不真正希望它能工作。

我也尝试在codeigniter目录树中的其他任何地方修改.htaccess文件。

你看过这个吗? 如何在codeigniter的路径中删除“ index.php”

您是否在配置文件中更改了index_path变量? 那是application / config / config.php,版本2.1.3中的第29行

在根目录和网站目录中都需要有一个htaccess文件。 它们都需要包含相同的内容,只是根目录中的文件需要更新索引的路径以包含您的网站目录。

根目录:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ yourwebsite/index.php/$1 [QSA,L]

网站目录:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

确保您的虚拟主机条目中包含以下内容:

    <Directory "/path...to directory">
        Order allow,deny
        Allow from all
        Allowoverride all
    </Directory>

    <IfModule mod_rewrite.c>
        RewriteEngine on
    </IfModule>

除了根目录外,您不需要修改任何.htaccess文件。 并且如上所述,请确保已在config.php文件中正确设置了所有内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM