【问题标题】:apache redirect url, rewrite and elb not workingapache重定向url,重写和elb不起作用
【发布时间】:2017-03-03 20:15:22
【问题描述】:

我确实在互联网上搜索过,但找不到有关它的答案。我对重写规则的了解非常有限或一无所知。有人可以帮助我或指出我正确的方向。

问题是这样的: - 我有一个网站:example.com

  • 我无法使用example.com 访问它,但使用example.com/example/ 可以正常工作
  • 我尝试了几个重写规则,但无法使其与example.com 一起使用
  • 这是我的.htaccess,它与example.com/example一起使用

    RewriteEngine On
    RewriteBase /example/
    
    RewriteCond $1 !^(index.php)
    RewriteCond %{REQUEST_URI} ^doc.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    
    RewriteCond %{REQUEST_URI} ^app.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    
    RewriteRule ^assets/uploads/.*\.(htaccess|htpasswd|ini|phps?|fla|psd|log|sh|zip|exe|pl|jsp|asp|htm|sh|cgi|py)$ - [F]
    
  • 此 Web 服务器也在 ELB 后面,我已在虚拟主机中添加此配置以将 http 重定向到 https

RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

如何让我的网络服务器使用example.com 访问它,并从http 重定向到https 请帮我改写规则等

提前致谢

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite url-rewriting


    【解决方案1】:

    以下规则应该适用于示例目录,请尝试,

    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)$ example/$1 [R=301,L]
    

    【讨论】:

    • 我得到了空白页,但它仍然对我不起作用。
    猜你喜欢
    • 2015-09-06
    • 1970-01-01
    • 2010-12-09
    • 2015-01-29
    • 1970-01-01
    • 2014-07-14
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    相关资源
    最近更新 更多