【问题标题】:.htaccess on xampp 2 problems.htaccess 关于 xampp 2 问题
【发布时间】:2017-09-27 05:30:21
【问题描述】:

config.http 文件

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

我的 .htaccess 代码

# Handle directory access

# Custom 404 File not Found Page
ErrorDocument 404 /templates/replace404.php

# Prevent file listing from the unscruplous
IndexIgnore *

# Rewrite for process.php
#RewriteRule ^do/([0-9a-zA-Z]+) process.php?opt=$1 [NC, L]

# Rewrite for article
# RewriteRule ^article/([0-9]+)/(09a-zA-Z_-)+) article.php?id=$1&title=$2 [NC, L]

好吧,第一个问题是它没有按预期抛出 replace404.php 页面,而是抛出标准 404 消息?该页面存在等,所以不知道为什么会这样。

其次是 process.php 的重写规则,如果我取消注释,那么当我尝试访问该站点时它会引发 500 错误????

【问题讨论】:

    标签: .htaccess xampp http-status-code-404


    【解决方案1】:

    对于这部分ErrorDocument 404 /templates/replace404.php,您必须检查文件的绝对路径。

    对于第二部分,在开始重写条件和规则之前先写RewriteEngine On

    RewriteRule ^do/([0-9a-zA-Z]+) process.php?opt=$1 [NC, L]
                                                          ^ this is the reason for 500
    

    改为使用下面

    RewriteRule ^do/([0-9a-zA-Z]+) process.php?opt=$1 [NC,L]
    

    【讨论】:

    • 感谢您的帮助。修复了 500 错误,是的,现在在 replace404.php 上表现得很奇怪。它被抛出但没有内容,收到错误 404 系统消息?
    • 很可能你有路径错误或错误,因为你的语法是正确的尝试用完整的主机名,如http://foo.example.com/templates/replace404.php
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-08
    • 1970-01-01
    • 2011-05-19
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多