Codeigniter “;未指定输入文件;在删除htaccess中的index.php和admin.php时发生
这是我的访问权限Codeigniter “;未指定输入文件;在删除htaccess中的index.php和admin.php时发生,codeigniter,Codeigniter,这是我的访问权限 RewriteEngine On AddType application/x-httpd-php53 .php SetEnv TZ Asia/Manila # If the user types just “admin”. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^admin$ admin\.php [L,QSA] # If the user ente
RewriteEngine On
AddType application/x-httpd-php53 .php
SetEnv TZ Asia/Manila
# If the user types just “admin”.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin$ admin\.php [L,QSA]
# If the user enter in any admin section, like “admin/section”.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin\/(.*)$ admin\.php/$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !index\.php
RewriteRule ^(.*)$ index.php/$1 [L]
在localhost上一切正常,但当我迁移到一个实时服务器时,这种情况就会发生我将假设您正在尝试删除codeigniter网站所有URL中的'index.php'。这是我当前使用的.htaccess文件,它工作正常。例如,如果我的网站URL是 www.test.com/index.php/home 结果会是 www.test.com/home
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
如果你想让“admin”这个词在你的URL中起同样的作用,那么就这样写吧
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
RewriteRule .* admin.php/$0 [PT,L]
编辑:
此外,您还提到了无法在live server上运行的更改。您的live web服务器是否在windows上运行
如果是这样,您需要在网站的根目录上有一个“web.config”文件。这就是它应该看起来的样子
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to index.php">
<match url="index.php|robots.txt|images|test.php" />
<action type="None" />
</rule>
<rule name="Rewrite CI Index">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="css|js|jpg|jpeg|png|gif|ico|htm|html|pdf|xls|xlsx" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
实际上,您是说删除了两条规则行?当你在那里重写COND时,你不能这么做。