如果url中没有index.php,Codeigniter链接将无法工作

如果url中没有index.php,Codeigniter链接将无法工作,php,codeigniter,Php,Codeigniter,我开发了一个使用codeigniter的web应用程序,我的web应用程序的所有URL的结构如下: <?php echo base_url();?>/Admin/Promotions /Admin/Promotions 这种类型的链接在我的Localhost中运行良好,但在我的托管服务器上不起作用(我使用的是Godaddy托管) 但有些URL中包含index.php的链接同时在本地主机和服务器上工作,这种链接之王的结构非常复杂 <?php echo base_url();?

我开发了一个使用codeigniter的web应用程序,我的web应用程序的所有URL的结构如下:

<?php echo base_url();?>/Admin/Promotions
/Admin/Promotions
这种类型的链接在我的Localhost中运行良好,但在我的托管服务器上不起作用(我使用的是Godaddy托管)

但有些URL中包含index.php的链接同时在本地主机和服务器上工作,这种链接之王的结构非常复杂

<?php echo base_url();?>index.php/Admin/Pramotions
index.php/Admin/Pramotions
我该怎么做才能让没有index.php的URL正常工作

我的访问权限:

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

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]

它对我有用…
.htaccess
文件是这样的

    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

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

使用此htaccess--

然后设置基本url--

然后删除配置文件中的index.php--


之后,它将在没有index.php的情况下工作,并打开config.php并执行以下操作

$config['index_page'] = "index.php"

替换

$config['uri_protocol'] ="AUTO"

并在HTACCESS文件中放入以下代码

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

如果上面的答案都不起作用,那么您可能需要在httpd.conf中激活mod_rewrite:

在终端上:

sudo nano /etc/httpd/conf/httpd.conf
ctrl+w以查找“重写”

取消对此行的注释:

LoadModule rewrite_module modules/mod_rewrite.so

保存并重新启动httpd(apache)。

您的
.htaccess
?index.php被.htaccess fle删除。检查您的.htaccess文件,但如何处理没有index.php的链接,例如(/Admin/Promotions)添加RewriteBase/your Folder Name/在RewriteEngine OnDeigniter自动添加到基本url后,您不需要执行此操作“/Admin/Promotions”只需使用最后一部分“Admin/Promotions”这个htaccess代码是否适用于未包含index.php的链接?使用您提供的htaccess代码,我收到错误“未指定输入文件”。@Abhijit Kumbhar:answer
$config['index_page'] = ""
$config['uri_protocol'] ="AUTO"
$config['uri_protocol'] = "REQUEST_URI"
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
sudo nano /etc/httpd/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so