【问题标题】:fuelphp can't access the page ( .htaccess is not working... )Fuelphp 无法访问该页面(.htaccess 无法正常工作...)
【发布时间】:2013-12-21 15:16:09
【问题描述】:

首先,我是FuelPHP的新手,所以这会很容易,但我在互联网上找不到答案,所以我希望你们能帮助我。

问题是我正在关注关于FuelPHP 的THIS 教程。

我在D:\www_ander\webshop 中设置了一个带有虚拟目录的 wamp。那是带有.htaccessindex.php 以及文件夹assets 的根目录

我在文件夹www_ander 中有fuel 文件夹。

我已经按照教程所说的(编辑配置/自动加载,创建文件和数据库)使用以下命令(我在文件夹 D:\www_ander 的命令提示符中运行了这个)

php oil generate scaffold messages name:string message:text
php oil refine migrate

我没有收到任何错误,并且数据库已成功创建。但是当我访问我的网站时(这是本地主机,我已经编辑了 windows 的主机文件):

http://webshop.nl/messages/

我得到一个404, Not Found 页面。我什至尝试将 /index/ 附加到 URL 中,但这也不起作用。

所以我的问题是,我做错了什么?为什么这不能正常工作?!?是我的网址错误还是其他问题?

也许无关紧要,但这里是.htaccess 文件:

# Multiple Environment config, set this to development, staging or production
# SetEnv FUEL_ENV production

<IfModule mod_rewrite.c>

    # Make sure directory listing is disabled
    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    #RewriteBase /wherever/fuel/is

    # Restrict your site to only one domain
    # !important USE ONLY ONE OPTION

    # Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    # Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #RewriteCond %{HTTP_HOST} (.+)$ [NC]
    #RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

    # Remove index.php from URL
    RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
    RewriteCond %{THE_REQUEST}              ^[^/]*/index\.php [NC]
    RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # deal with php5-cgi first
    <IfModule mod_fcgid.c>
        RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>

    <IfModule !mod_fcgid.c>

        # for normal Apache installations
        <IfModule mod_php5.c>
            RewriteRule ^(.*)$ index.php/$1 [L]
        </IfModule>

        # for Apache FGCI installations
        <IfModule !mod_php5.c>
            RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
        </IfModule>

    </IfModule>

</IfModule>

----- 更新 ------

我仍在寻找答案,但我已经找到了解决方法。当我访问http://webshop.nl/index.php/messages/ 时,它确实有效。所以看起来 .htaccess 没有完全工作。但据我所知,它应该可以工作。那么你们知道哪里出了问题吗?

【问题讨论】:

    标签: php .htaccess http-status-code-404 fuelphp


    【解决方案1】:

    我已经找出问题所在。 Id 与我的虚拟主机设置有关。

    问题是我没有指定允许覆盖。所以在我将这部分插入我的虚拟主机文件后,它就起作用了:

    <Directory "D:\www_ander">
        AllowOverride All
    </Directory>
    

    所以整个虚拟主机文件现在看起来像这样:

    <Directory D:\www_ander\>
        Order Deny,Allow   
        Allow from all 
    </Directory>
    
    <VirtualHost *:80>   
        DocumentRoot "D:\www_ander" 
        ServerName webshop.nl
        ServerAlias www.webshop.nl
        <Directory "D:\www_ander">
            AllowOverride All
        </Directory>
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-07
      • 2012-08-05
      • 1970-01-01
      相关资源
      最近更新 更多