Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess重写规则在codeigniter中不工作_Php_.htaccess_Codeigniter_Rewrite - Fatal编程技术网

Php htaccess重写规则在codeigniter中不工作

Php htaccess重写规则在codeigniter中不工作,php,.htaccess,codeigniter,rewrite,Php,.htaccess,Codeigniter,Rewrite,在这里,我试图从codeigniter应用程序的URL中删除index.php 为此,我编写了如下.htaccess文件: # Turn on URL rewriting RewriteEngine On # Installation directory # RewriteBase /projectname/ # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From

在这里,我试图从codeigniter应用程序的URL中删除index.php

为此,我编写了如下.htaccess文件:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
# RewriteBase /projectname/

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php [PT]

它正在xx.xx.xx.xxx服务器和mydomain.com中工作。在这里,我尝试将相同的副本复制到另一台服务器yy.yy.yy.yyy。在这种情况下,重写URL不起作用。如果我使用'yy.yy.yy/index.php/login',它工作正常。但是'yy.yy.yy/login',它会抛出'请求的URL/projectname/login在此服务器上找不到。'错误。

对于主目录。htaccess请尝试此操作,然后从config.php中删除index.php

Options +FollowSymLinks
Options -Indexes

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
    Order deny,allow
    Deny from all
</FilesMatch>

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
请勿触摸应用程序目录中的.htaccess文件