【问题标题】:HTACCESS works in localhost but not in remote hostHTACCESS 在 localhost 中有效,但在远程主机中无效
【发布时间】:2014-08-13 10:32:35
【问题描述】:

我知道这已经问了很多次了,但是我尝试过的解决方案都没有奏效。 所有这些在我的本地主机中都可以正常工作。但是在我上传到远程主机后,所有控制器链接都需要预先附加到它们的“index.php/”才能使它们工作。

htaccsess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L] 

.htaccess 文件位于 CI 根文件夹中。

我的配置:

$config['base_url'] = "http://".$_SERVER['SERVER_NAME']."/";
$config['index_page'] = "";
$config['uri_protocol'] = 'AUTO';

我已经尝试将 uri_protocol 更改为“REQUEST_URI”和“ORIG_PATH_INFO”,但仍然不满意。 我听说有一个步骤涉及设置 httpd.conf 文件并将“AllowOverride”更改为“ALL”。但我想我无法访问远程服务器(共享)中的 httpd.conf。

任何帮助将不胜感激。

【问题讨论】:

  • 我不知道共享主机究竟是如何工作的,但它应该是一种改变你的虚拟主机的apache配置的方法
  • 或者您可能需要将RewriteBase / 添加到您的.htaccess 中

标签: php apache .htaccess codeigniter


【解决方案1】:
 Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

#RewriteEngine on
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$0 [PT,L]  

在本地和远程都适合我..

【讨论】:

  • 感谢 m8,您是救生员。我多么爱如此。你们真棒! :p
猜你喜欢
  • 2013-10-24
  • 2014-05-01
  • 1970-01-01
  • 2015-04-20
  • 2023-03-22
  • 1970-01-01
  • 2018-12-03
  • 2021-11-02
  • 1970-01-01
相关资源
最近更新 更多