【问题标题】:Redirect to another website without changing the URL在不更改 URL 的情况下重定向到另一个网站
【发布时间】:2018-07-30 13:02:18
【问题描述】:

我们有一个在 Elastic Loadbalancer 后面运行的 AWS beanstalk WordPress 应用程序,并且希望 WP 网站从具有云端的 S3 网站之一打开一个页面,而无需更改地址栏中的 URL。例如 wpbeanstalk.com/xyz 应该打开 s3website.com/a1/page.html。我曾尝试在 Htaccess 中使用 RewriteRule 执行此操作,但 URL 更改为 301,我现在使用 Iframe 在 WP 应用程序上加载 S3website 页面,但这不是一个可行的解决方案。任何人都可以建议实现这一目标的最佳实践吗?

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
  RewriteEngine On 
  RewriteBase / 
  RewriteRule ^index\.php$ - [L] 

  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteRule . /index.php [L] 

  RewriteCond %{REQUEST_URI} .ride/$ 
  RewriteRule (.*) awsS3.Website.com/f1/index.html [R=301,L] 
</IfModule>

【问题讨论】:

  • 请出示您的 RewriteRules。
  • @DusanBajic # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d重写规则。 /index.php [L] RewriteCond %{REQUEST_URI} .ride/$ RewriteRule (.*) awsS3.Website.com/f1/index.html [R=301,L]
  • 如果您将[R=301,L] 更改为[P,L] 会发生什么?
  • @DusanBajic 我能够使用[P,L] 进行重定向,但是 S3 存储桶网站有一个带有 SSL 证书的 cloundfront,当我点击所需的 URL 时,浏览器会尝试访问 S3 网站但它因 Cloudfront 错误请求而失败。 Cloudfront 设置为 S3 网站 Endpoint 的自定义来源。我想知道如何通过这个 - 请告知您对此的想法。谢谢!

标签: apache .htaccess redirect amazon-s3 amazon-elastic-beanstalk


【解决方案1】:

您可以将 CloudFront 放在您的 Wordpress 站点和 S3 存储桶的前面,然后配置一个 Lamdba@edge 函数以使用正确的 S3 文件修改源响应。

【讨论】:

  • 这可以为网站/域而不是 s3 文件完成吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-22
  • 1970-01-01
  • 1970-01-01
  • 2013-10-12
  • 1970-01-01
  • 2013-08-11
相关资源
最近更新 更多