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
Apache 我怎样才能删除“;index.php“;从我的链接?_Apache_.htaccess_Codeigniter - Fatal编程技术网

Apache 我怎样才能删除“;index.php“;从我的链接?

Apache 我怎样才能删除“;index.php“;从我的链接?,apache,.htaccess,codeigniter,Apache,.htaccess,Codeigniter,通常我访问这样的页面:http://localhost/codeigniter/index.php/auth/login 但是,我希望能够像这样访问页面:http://localhost/codeigniter/auth/login 我没有关于http.conf和.htaccess配置的信息 我已经设置了$config['index\u page']=''incodeigniter/application/config/config.php 我的http.conf文件是默认的,除了取消注释“Lo

通常我访问这样的页面:
http://localhost/codeigniter/index.php/auth/login
但是,我希望能够像这样访问页面:
http://localhost/codeigniter/auth/login

我没有关于
http.conf
.htaccess
配置的信息

我已经设置了
$config['index\u page']=''
in
codeigniter/application/config/config.php

我的http.conf文件是默认的,除了取消注释“
LoadModule rewrite\u modules/mod\u rewrite.so

我检查了许多建议的.htaccess文件,但我无法理解重写规则背后的逻辑

以下是我最成功的
.htaccess
内容。它位于
/www/CodeIgniter/

(我所说的最成功是指,这是唯一一个由CodeIgniter而不是服务器创建的404错误。)

重写选项继承
选项-索引
选项+FollowSymLinks
基准/编码点火器/
#设置索引的默认文件
DirectoryIndex.php
#激活URL重写
重新启动发动机
#不要重写指向文档、资产和公共文件的链接
1美元^(图像|资产|上传|验证码)
#不要在文档根、robots.txt或维护页面中重写php文件
1美元^([^\..]+\.php | robots\.txt)
#但是重写其他的一切
重写规则^(.*)$index.php/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
ErrorDocument 404 index.php
我讨厌要求直接解决方案,但不幸的是,这是我最后的选择:/
你能给我一个解决问题的正确方法吗?

把这个放到你的htaccess上

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

重新启动发动机
1美元^(索引\.php | resources | robots\.txt)
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]

确保在服务器上启用了“重写”模块

将其置于htaccess上

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

重新启动发动机
1美元^(索引\.php | resources | robots\.txt)
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L,QSA]
确保服务器上已启用“重写”模块

这是我的重复答案:

请在项目文件夹中创建.htaccess文件并写入:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 

</IfModule>
<IfModule !mod_rewrite.c>
 ErrorDocument 404 index.php
</IfModule>
这是我重复的回答:

请在项目文件夹中创建.htaccess文件并写入:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 

</IfModule>
<IfModule !mod_rewrite.c>
 ErrorDocument 404 index.php
</IfModule>

这是我发现的最简单的一个对我有效的方法:-

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

这是我发现的最简单的一个对我有效的方法:-

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

尝试为此
RewriteBase/
替换
RewriteBase/
,使
.htaccess
文件看起来或多或少正确。如果链接未通过,则可能是CodeIgniter问题。正如manix所说,
RewriteBase
之后的位是域之后到.htaccess所在主目录的路径,您声明该路径为
/CodeIgniter/
,因此应该是正确的。服务器上是否启用了rewritemodule?检查.htaccess文件是否正常工作。尝试替换
RewriteBase/CodeIgniter/
,以使
RewriteBase/
文件看起来或多或少正确。如果链接未通过,则可能是CodeIgniter问题。正如manix所说,
RewriteBase
之后的位是域之后到.htaccess所在主目录的路径,您声明该路径为
/CodeIgniter/
,因此应该是正确的。服务器上是否启用了rewritemodule?检查.htaccess文件是否正常工作。