【问题标题】:htaccess on hosted website in MVC architecturehtaccess 在 MVC 架构中的托管网站上
【发布时间】:2017-06-30 13:50:20
【问题描述】:

这在 localhost 上运行良好: 但不适用于我的托管网站(由 Hostinger.fr 提供)

RewriteBase /
RewriteEngine On
RewriteCond expr "%{REQUEST_URI} -strmatch '*admin/*'"
RewriteRule (.*) $1  [L] 
RewriteCond expr "%{REQUEST_URI} -strmatch '*journal/*'"
RewriteRule (.*) $1  [L]
RewriteRule (.*) webroot/$1 [L]

这些行之后(在处理之后)是另一个指向 webroot 目录的 htaccess:

RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php/$1 [L]

它用于向我显示第一页,因为 index.php 存在于那里的 webroot 目录中,但不显示内部页面。 我使用MVC结构对站点进行编码,并且没有直接指示调用的程序 通过单击 index.php 页面显示的菜单中的一个选项,它只向我显示一个带有消息“未指定输入文件”的空页面。 webroot index.php 没有被调用(像第一次那样)以继续开发真正的程序来调用。

谁能建议我在 .htaccess 中需要做什么?

注意:Hostinger 希望“Rewrite Base /”命令必须放在首位

【问题讨论】:

    标签: php .htaccess web-hosting


    【解决方案1】:

    我没有时间测试您的 htaccess,但是您可以尝试一些事情:

    1. 确保您的文件权限正确。对于大多数主机提供商,htaccess(和所有其他文件)必须具有 644 权限才能工作

    2. 检查Apache的rewrite模块是否安装并激活。通常,主机提供商默认启用此功能,但可能某些提供商会要求您在其控制面板上手动激活模块

    3. 检查您的文件系统目录树并确保父目录中没有任何其他可能覆盖您的 htaccess 行为的 htaccess 文件

    例如,如果你有一个文件在/home/your_user/public_html/.htaccess 和一个文件在/home/your_user/public_html/my_sub_app/.htaccess,那么如果第一个htaccess 有这样的指令:

    <Directory>
        Order Deny,Allow
        Deny from all
    </Directory>
    

    它将阻止第二个 htaccess 覆盖该行为

    【讨论】:

    • 感谢您的研究线索,但我已经验证了它们,Hostinger 一切都很好。为 htaccess 文件的第一行建议的命令仅导致错误 500
    猜你喜欢
    • 2023-03-19
    • 2023-03-27
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    相关资源
    最近更新 更多