为什么我的HTACCESS上传到Ionos Webspe时无法使用?
我已经尝试过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的位置相同的位置。 php
,news.php
和seksikateg.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的主机上,可能会在主机上启用多视图,这将破坏您的规则,因为这会在mod_rewrite处理请求之前附加
.php
扩展名。但是,您的指示也处于错误的顺序。附加
.php
扩展程序的通用重写应在其他规则之后出现。您的重写以附加
.php
扩展名并不严格正确,因为在某些情况下可能会导致重写循环(500错误)。反而尝试一下:
我还将串联锚式的锚添加到了现有重写的正则时,否则您可能会匹配太多。例如。
/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:
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 tonews.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.