【问题标题】:Codeigniter App with Symlink -Remove index.php from URL带有符号链接的 Codeigniter 应用程序 - 从 URL 中删除 index.php
【发布时间】:2013-07-28 10:01:30
【问题描述】:

我在这里和网络的其他地方浏览了许多资源,但似乎无法使其工作。 我在主目录中有 codeigniter 应用程序。符号链接在 /var/www/html 中创建。 下面的链接可以正常工作。

http://mydomain.net/dms/index.php/welcome

但是没有 index.php ,我希望下面的链接可以工作

http://mydomain.net/dms/welcome

代码点火器 2.1.1 目录:

dms
    application
    system
    index.php
    .htaccess

配置.php

$config['index_page'] = ""; 
$config['uri_protocol'] = "AUTO";

routes.php

$route['default_controller'] = "welcome";

配置文件 httpd.conf

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>
Alias /dms/ "/var/www/html/dms/"
<Directory "/var/www/html/dms">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

符号链接

ls -l /var/www/html
dms -> /home/user1/dms

.htaccess 文件:

RewriteEngine On
# enable symbolic links
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+) index.php [L]

我尝试将 .htaccess 文件保存在 CI 文件夹文件夹 /home/user1/dms 中,稍后保存在 /var/www/html 中 两者都没有工作。 我收到错误(在 http 错误日志中)

"File does not exist: /var/www/html/dms/welcome"

请帮忙。

【问题讨论】:

  • .htaccess 文件由下面的 Christian Giupponi 给出,我在 cmets 中提到的更正有效。不需要服务器级别的 AllowOverride All,但必须在特定目录级别。谢谢

标签: codeigniter


【解决方案1】:

我使用这个 .htaccess,它对我有用,试试:

   <IfModule mod_rewrite.c>
        # Make sure directory listing is disabled
        Options +FollowSymLinks -Indexes
        # disable the Apache MultiViews directive if it is enabled on the server. It plays havoc  with URL rewriting
        Options -MultiViews
        RewriteEngine on

        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php?/$1 [L]
        </IfModule>

    </IfModule>

【讨论】:

  • 我将 codeigniter app 目录中的 .htaccess 文件更改为您在上面给出的内容。现在我收到 500 内部错误。日志文件显示 - 由于可能的配置错误,请求超出了 10 个内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。有什么提示吗?
  • RewriteRule ^([^/]*)$ index.php/$1 [L] 和 RewriteRule ^([^/]*)$ index.php?/$1 [L] 有效。谢谢
猜你喜欢
  • 1970-01-01
  • 2016-05-14
  • 2014-10-28
  • 2012-06-15
  • 2012-09-21
  • 2011-10-12
  • 2017-07-16
相关资源
最近更新 更多