我的应用程序运行在https://example.com/app上。我想把https://example.com/重定向到https://example.com/app。我在site中的重定向规则如下。如何根据我的需要修改它?
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule (.*) https://%{HTTP:Host}%{REQUEST_URI} [L,R=PERMANENT]发布于 2020-07-01 14:15:52
如果您希望重定向您的客户端(HTTP 301),请尝试如下:
# Redirect entire site ("/") without Query-Strings
Redirect 301 / http://www.example.com/app/# Redirect all requests to "/" with Query-Strings
RewriteRule ^(.*) http://www.example.com%{REQUEST_URI} [R=301,NC]如果您想要重写请求(内部):
RewriteEngine on
RewriteBase /
# Condition: Rewrite all URLS without app in them ...
RewriteCond %{REQUEST_URI} !^/app/
# Condition:Rewrite all URLS from Domain ...
RewriteCond %{HTTP_HOST} ^(www\.)?example\.
# Action: Rewrite to insert /app/
RewriteRule ^(.*)$ /app/$1 [L]https://serverfault.com/questions/1023556
复制相似问题