htaccess - 将流量从一个 URL 重定向到另一个 URL

发布于 2025-01-08 04:30:28 字数 457 浏览 2 评论 0原文

任何人都可以建议我如何将以下路径的任何流量重定向到另一个目录,

images/flash/main.swf?config=/flash/flash_output/133/location.htm

这应该 301 重定向到另一个 URL(例如 www.site.com)

我遇到的问题是?导致 Codeigniter(版本 2)出现问题的字符,因为这会导致以下错误 - 您提交的 URI 包含不允许的字符。 我正在尝试使用 htaccess 文件而不是 codeigniter 中的路由选项来解决该问题。

我当前允许的 uri 字符配置如下(标准设置)

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

- 我不想添加 ?出于安全考虑,如果可能的话,请在此进行(文档指出不应更改)

Can anyone suggest how I can redirect any traffic the following path to another directory

images/flash/main.swf?config=/flash/flash_output/133/location.htm

this should 301 redirect to another URL (eg www.site.com)

The issue I get is the ? character which causes a problem with Codeigniter (version 2), as this causes the following error - The URI you submitted has disallowed characters.
I am trying to use the htaccess file rather than the routes option in codeigniter to remedy the problem.

My current permitted uri chars config is below (the standard setting)

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

- I don't want to add the ? to this if possible here due to security concerns (the documentation states that this should not be changed)

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

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

发布评论

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

评论(1

留一抹残留的笑 2025-01-15 04:30:28

假设 imagesdocumentroot 中存在的目录,

将其添加到 DocumentRoot 中的 .htaccess

RewriteEngine On
RewriteBase /

Rewrite %{REQUEST_URI}?%{QUERY_STRING} images/flash/main\.swf\?config\=/flash/flash_output/133/location\.htm
RewriteRule ^ www.site.com [R=301,L]

Assuming that images is a directory present in documentroot

Add this to your .htaccess in DocumentRoot

RewriteEngine On
RewriteBase /

Rewrite %{REQUEST_URI}?%{QUERY_STRING} images/flash/main\.swf\?config\=/flash/flash_output/133/location\.htm
RewriteRule ^ www.site.com [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文