为什么我的HTACCESS上传到Ionos Webspe时无法使用?

发布于 2025-02-03 03:07:12 字数 597 浏览 3 评论 0原文

我已经尝试过Localhost的工作正常工作,但是将其上传到Ionos Webspace之后,网站索引正在正常工作,但是在我单击内容之后,它没有引导到任何地方,并且有一个错误消息:

错误404不陷入困境,您的浏览器找不到与您输入的URL相对应的文档。

这是我的.htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^news/([0-9a-zA-Z_-]+) news.php?url=$1 [NC,L]

RewriteRule ^seksikateg/([0-9a-zA-Z_-]+) seksikateg.php?kategori=$1 [NC,L]

我将他放在与index的位置相同的位置。 phpnews.phpseksikateg.php

I've tried in in my localhost at it worked fine but after I upload it to my ionos webspace the website index is working but after I click the content it is not directing to anywhere and there is an error message:

Error 404 not foound, Your browser can't find the document corresponding to the URL you typed in.

Here is my .htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^news/([0-9a-zA-Z_-]+) news.php?url=$1 [NC,L]

RewriteRule ^seksikateg/([0-9a-zA-Z_-]+) seksikateg.php?kategori=$1 [NC,L]

and i placed he file in the same place as the index.php, news.php, and seksikateg.php

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

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

发布评论

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

评论(1

一刻暧昧 2025-02-10 03:07:12

在您的主机上,可能会在主机上启用多视图,这将破坏您的规则,因为这会在mod_rewrite处理请求之前附加.php扩展名。

但是,您的指示也处于错误的顺序。附加.php扩展程序的通用重写应在其他规则之后出现。

您的重写以附加.php扩展名并不严格正确,因为在某些情况下可能会导致重写循环(500错误)。

反而尝试一下:

# Ensure that MutliViews is disabled
Options -MultiViews

RewriteEngine on

RewriteRule ^news/([0-9a-zA-Z_-]+)$ news.php?url=$1 [NC,L]

RewriteRule ^seksikateg/([0-9a-zA-Z_-]+)$ seksikateg.php?kategori=$1 [NC,L]

# Append ".php" extension on other URLs
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ $1.php [L]

我还将串联锚式的锚添加到了现有重写的正则时,否则您可能会匹配太多。例如。 /news/foo/bar/baz也将被重写为news.php?url = foo - 可能创建重复的内容并打开您的网站以滥用。

我还会质疑这些重写上nc标志的使用。如果需要,那么您可能会出现重复的内容问题。

无需在REGEX字符类中返回斜线escape文字点,而nc标志在最后一个规则上肯定是多余的。

It's possible that MultiViews is enabled at your host and this will break your rules since this will append the .php extension before mod_rewrite processes the request.

However, your directives are also in the wrong order. The generic rewrite to append the .php extension should appear after the other rules.

Your rewrite to append the .php extension is not strictly correct as it could result in a rewrite loop (500 error) under certain circumstances.

Try it like this instead:

# Ensure that MutliViews is disabled
Options -MultiViews

RewriteEngine on

RewriteRule ^news/([0-9a-zA-Z_-]+)$ news.php?url=$1 [NC,L]

RewriteRule ^seksikateg/([0-9a-zA-Z_-]+)$ seksikateg.php?kategori=$1 [NC,L]

# Append ".php" extension on other URLs
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^.]+)$ $1.php [L]

I've also added the end-of-string anchor to the regex of your existing rewrites, otherwise you are potentially matching too much. eg. /news/foo/bar/baz would have also been rewritten to news.php?url=foo - potentially creating duplicate content and opening up your site to abuse.

I would also question the use of the NC flag on these rewrites. If this is required then you potentially have a duplicate content issue.

No need to backslash-escape literal dots in a regex character class and the NC flag is certainly redundant on the last rule.

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