gpt4 book ai didi

apache - 无效命令 'RedirectMatch' - Apache 2.47。 Ubuntu 信任

转载 作者:行者123 更新时间:2023-12-04 19:02:25 26 4
gpt4 key购买 nike

我有一个 .htaccess 文件,如下所示,但出现错误Invalid command 'RedirectMatch', perhaps misspelled or defined by a module not included in the server configuration .我已经做了很多搜索,但找不到问题所在,mod rewrite 已加载并且似乎可以正常工作。

我在 Ubuntu 14.04 上运行 Apache 2.4.7。

任何帮助或指导都会很棒。

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite
#
RewriteBase /

# force www on domain
# RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]

# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) error [R=301,L]

# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) error [R=301,L]

# leave robots.txt alone for search engines
RewriteRule ^robots.txt robots.txt [L]

# redirect /cashback to home
RedirectMatch 301 ^/cashback/?$ http://www.example.com/

# add trailing slash to links
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

谢谢

最佳答案

mod rewrite is loaded and seemingly working otherwise.
RedirectMatch 301 ^/cashback/?$ http://www.example.com/


RedirectMatch是 mod_alias 的一部分,而不是 mod_rewrite。虽然 mod_alias 通常默认加载,除非它已被明确删除?

但是,您不应该混合使用 mod_alias 和 mod_rewrite 重定向。由于它们属于不同的模块,它们在不同的时间执行(通常首先是 mod_rewrite),因此您可能会遇到意外的冲突。由于您已经将 mod_rewrite 用于其他所有内容,因此您应该改用 mod_rewrite (即 RewriteRule )重新处理此重定向。像这样:
RewriteRule ^cashback/?$ / [R=301,L]

关于apache - 无效命令 'RedirectMatch' - Apache 2.47。 Ubuntu 信任,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34755923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com