【问题标题】:Codeigniter application index.php removed randomly in url on amazon EC2 clound serverCodeigniter 应用程序 index.php 在亚马逊 EC2 云服务器上的 url 中随机删除
【发布时间】:2016-02-06 03:42:09
【问题描述】:

我正在开发一个 Web 应用程序。在云亚马逊 EC2 实例 1 上导航应用程序时,我遇到了一个非常奇怪的问题,它随机选择一些链接,当我点击这些链接时,它会将我重定向到未找到的页面或有时主页或登录页面上的某个时间。虽然会话仍然存在。

以前我添加了.htaccess 文件以从网址中删除index.php,但在注意到此问题后我已恢复更改但我的re_write_mode 仍然在apache httpd.conf 文件和.htaccess 文件中启用在带有注释代码的应用程序的根目录上。

下面提到的Apache配置。

DocumentRoot "/var/www/html"

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory "/var/www/html">
    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny
    Allow from all

</Directory>

【问题讨论】:

    标签: apache .htaccess codeigniter amazon-ec2 centos


    【解决方案1】:

    不知道为什么你会从你发布的内容中遇到这个问题......这是我在所有 CI 项目的根目录中使用的 .htaccess 文件,用于从 URL 中删除 index.php

    RewriteEngine On
    
    # Put your installation directory here:
    # If your URL is www.example.com/, use /
    # If your URL is www.example.com/site_folder/, use /site_folder/
    
    RewriteBase /
    
    # Do not enable rewriting for files or directories that exist
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # For reuests that are not actual files or directories,
    # Rewrite to index.php/URL
    RewriteRule ^(.*)$ index.php/$1 [PT,L]
    

    你的 apache 配置看起来没有什么特别的地方。我会说这听起来更像是您的“路线”的问题。您的应用中是否设置了任何自定义路线?

    另外,您是否更改了配置文件中的 $config['index_page'] 和/或 $config['base_url']?

    【讨论】:

    • 感谢您的回复。请检查我上面提到的配置文件设置 $config['base_url'] = "http://".$_SERVER['SERVER_NAME']."/[application_name]/"; $config['index_page'] = 'index.php';尽管存在会话,但也存在将某些页面重定向到登录页面的问题。不知道为什么会发生这种情况,因为具有设置和配置的相同应用程序在本地系统上运行完美,但在 amazon clound ec2 上出现问题。
    • 目前我面临不断重定向到登录页面的问题。
    • 听起来这可能是您的逻辑中的某个问题。如果不查看您如何检查某人是否“登录”等,就很难知道......
    猜你喜欢
    • 2023-03-10
    • 2017-11-30
    • 1970-01-01
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    • 1970-01-01
    • 2011-10-26
    相关资源
    最近更新 更多