奇怪的 htaccess 问题

发布于 2024-10-30 19:06:36 字数 605 浏览 1 评论 0原文

我在 .htaccess 中有一个网站,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?menu=$1 [L,QSA]

#DirectoryIndex index.php

我的问题是,如果我更改一个字母,网站就会呈现 500 错误。即使我清空整个文件,它仍然显示 500 错误。

我想做的是,域上有一个这样的页面
http://www.example.co.uk/brochure/generate.php

文件 generate.php 确实存在于 /brochure/ 目录中。

generate.php 仍然没有加载,它正在加载 index.php 文件。

有什么帮助吗?

I have a website with this in the .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?menu=$1 [L,QSA]

#DirectoryIndex index.php

My problem is even, if I change a single letter the website is rendering a 500 Error. Even if I empty complete file, it still shows me the 500 Error.

What I want to do is, there is a page like this on the domain
http://www.example.co.uk/brochure/generate.php

The file generate.php does exist in /brochure/ directory.

But still the generate.php does not load and it is loading the index.php file.

Any help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

毁梦 2024-11-06 19:06:36

尝试以下我知道应该有效的操作:

<IfModule mod_rewrite.c>
    #Turn the Rewrite Engine ON
    RewriteEngine On

    #Set the base where to rewrite the requests
    RewriteBase /

    #Allow direct file access
    RewriteCond %{REQUEST_FILENAME} !-f

    #Allow direct directory access
    RewriteCond %{REQUEST_FILENAME} !-d

    #Disallow certain files.
    RewriteCond %{REQUEST_FILENAME} !brochure\/generate\.php$

    #Rewrite URLS To GET[menu] and make sure this is the last rule.
    RewriteRule ^(.*)$ index.php?menu=$1 [L]
</IfModule>

如果您没有看到任何重写发生,请检查是否安装了重写模块。

Try the following which I know should work:

<IfModule mod_rewrite.c>
    #Turn the Rewrite Engine ON
    RewriteEngine On

    #Set the base where to rewrite the requests
    RewriteBase /

    #Allow direct file access
    RewriteCond %{REQUEST_FILENAME} !-f

    #Allow direct directory access
    RewriteCond %{REQUEST_FILENAME} !-d

    #Disallow certain files.
    RewriteCond %{REQUEST_FILENAME} !brochure\/generate\.php$

    #Rewrite URLS To GET[menu] and make sure this is the last rule.
    RewriteRule ^(.*)$ index.php?menu=$1 [L]
</IfModule>

if you do not see any rewriting taking palce then check to see the module for rewrite is installed.

三人与歌 2024-11-06 19:06:36

如果文件也触发了500状态代码,那么错误就在其他地方:您没有编辑Apache正在使用的真实.htaccess文件,错误就会出现 在任何情况下,您都

应该找到错误日志:那里显示了确切的详细信息。在 Linux 中,它通常位于 /var/log/httpd 下。在 Windows 中,它可以位于 %ProgramFiles%\Apache Software Foundation\Apache2.2\logs 下。如果它是共享主机帐户,您的控制面板中可能会有“错误”或“日志”功能。

If an empty file triggers a 500 status code as well, then the error is somewhere else: you are not editing the real .htaccess file being used by Apache, the error comes from the application, etc.

In any case, you should find the error log: that's where the exact details are shown. In Linux, it's normally under /var/log/httpd. In Windows, it can be under %ProgramFiles%\Apache Software Foundation\Apache2.2\logs. If it's a shared hosting account, you'll probably have an "Errors" or "Logs" feature in your control panel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文