Chúng tôi có những điều sau đây:
- Trang web tĩnh WordPress tại
https://www.domain1.com
.
- Ứng dụng web React/Django tại
https://www.domain2.com
với ba URI chính:
Chúng tôi muốn chúng xuất hiện giống như chúng là cùng một miền tại https://www.domain1.com
. Tôi đã nói rằng điều này có thể được thực hiện bằng cách thiết lập một Proxy đảo ngược trên máy chủ web Apache tại https://www.domain1.com
. Do đó, chúng tôi phải di chuyển hiện tại /
của https://www.domain2.com
, đến /cổng thông tin
hoặc /bảng điều khiển
, đó là không có vấn đề.
Điều gì sẽ xảy ra nếu có một liên kết đến https://www.domain1.com/portal/*
, nó sẽ phục vụ https://www.domain2.com/portal/*
, nhưng vẫn sẽ nói https://www.domain1.com/portal/*
trong trình duyệt. Do đó, có vẻ như cùng một trang web đối với người dùng mặc dù nó đến từ miền khác.
Dù sao, vì vậy tôi đang cố gắng sửa đổi .htaccess
vì https://www.domain1.com/
bằng cách thêm phần sau vào đầu:
ProxyPass "/portal" "https://www.domain2.com/portal"
ProxyPassReverse "/portal" "https://www.domain2.com/portal"
# hoặc chỉ
ProxyPass "/portal" "https://www.domain2.com/"
ProxyPassReverse "/portal" "https://www.domain2.com/"
Điều này gây ra một 500
lỗi trên toàn bộ trang web WordPress.
Đây là toàn bộ của .htaccess
:
ProxyPass "/portal" "https://www.domain2.com/portal"
ProxyPassReverse "/portal" "https://www.domain2.com/portal"
# BẮT ĐẦU WpFastestCache
# Thời gian sửa đổi: 21-09-21 9:26:57
<IfModule mod_rewrite.c>
Viết LạiEngine Trên
viết lại cơ sở /
RewriteCond %{HTTPS} =bật
RewriteCond %{HTTP_HOST} ^www.domain1.com
# Bắt đầu Loại trừ WPFC
# Kết thúc Loại trừ WPFC
# Bắt đầu_WPFC_Loại trừ_Quản trị viên_Cookie
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\[email protected]
RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=ad,om
# Kết thúc_WPFC_Exclude_Admin_Cookie
RewriteCond %{HTTP_HOST} ^www.domain1.com
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WP_FASTEST_CACHE_CSS_VALIDATOR|Twitterbot|LinkedInBot|WhatsApp|Mediatoolkitbot)
RewriteCond %{HTTP_USER_AGENT} !(WP\sFastest\sCache\sPreload(\siPhone\sMobile)?\s*Bot)
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{REQUEST_URI} ![^\/]+\/$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !comment_author_
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobile
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /nfs/c09/h02/mnt/135490/domains/domain1.com/html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "index\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
TệpETTag Không có
Bỏ đặt tiêu đề ETag
Tiêu đề đặt Kiểm soát bộ đệm "max-age=0, không có bộ đệm, không lưu trữ, phải xác thực lại"
Bộ tiêu đề Pragma "no-cache"
Bộ tiêu đề Hết hạn "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# KẾT THÚC WpFastestCache
# BẮT ĐẦU GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-phông chữ/woff .woff
AddType x-phông chữ/ttf .ttf
AddOutputFilterByType DEFLATE hình ảnh/svg+xml
AddOutputFilterByType DEFLATE văn bản/đồng bằng
AddOutputFilterByType DEFLATE văn bản/html
AddOutputFilterByType DEFLATE văn bản/xml
AddOutputFilterByType DEFLATE văn bản/css
AddOutputFilterByType DEFLATE văn bản/javascript
Ứng dụng AddOutputFilterByType DEFLATE/xml
AddOutputFilterByType DEFLATE ứng dụng/xhtml+xml
AddOutputFilterByType DEFLATE ứng dụng/rss+xml
AddOutputFilterByType DEFLATE ứng dụng/javascript
AddOutputFilterByType DEFLATE ứng dụng/x-javascript
Ứng dụng AddOutputFilterByType DEFLATE/x-font-ttf
AddOutputFilterByType DEFLATE x-font/ttf
Ứng dụng AddOutputFilterByType DEFLATE/vnd.ms-fontobject
AddOutputFilterByType XÁC ĐỊNH phông chữ/phông chữ opentype/phông chữ ttf/phông chữ eot/otf
</IfModule>
# KẾT THÚC GzipWpFastestCache
# BẮT ĐẦU LBCWpFastestCache
<FilesMatch "\.(webm|ogg|mp4|ico|pdf|flv|avif|jpg|jpeg|png|gif|webp|js|css|swf|x-html|css|xml|js|woff|woff2| otf|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
Ứng dụng AddType/phông chữ woff2 .woff2
Ứng dụng AddType/x-font-opentype .otf
ExpiresActive On
Hết hạn Mặc định A0
ExpiresByType video/webm A10368000
ExpiresByType video/ogg A10368000
ExpiresByType video/mp4 A10368000
Hình ảnh ExpiresByType/avif A10368000
ExpiresByType hình ảnh/webp A10368000
ExpiresByType ảnh/gif A10368000
ExpiresByType image/png A10368000
ExpiresByType image/jpg A10368000
Hình ảnh ExpiresByType/jpeg A10368000
Hình ảnh ExpiresByType/ico A10368000
Hình ảnh ExpiresByType/svg+xml A10368000
ExpiresByType văn bản/css A10368000
ExpiresByType văn bản/javascript A10368000
Hết hạnByType ứng dụng/javascript A10368000
Ứng dụng ExpiresByType/x-javascript A10368000
Ứng dụng ExpiresByType/font-woff2 A10368000
Ứng dụng ExpiresByType/x-font-opentype A10368000
Ứng dụng ExpiresByType/x-font-truetype A10368000
</IfModule>
<IfModule mod_headers.c>
Bộ tiêu đề Hết hạn "max-age=A10368000, public"
Bỏ đặt tiêu đề ETag
Bộ tiêu đề Giữ kết nối
TệpETTag Không có
</IfModule>
</FilesMatch>
# KẾT THÚC LBCWpBộ nhớ cache nhanh nhất
# Chuyển hướng vĩnh viễn / https://www.domain1.com
Viết LạiEngine Trên
RewriteCond %{HTTPS} !=bật
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BẮT ĐẦU WordPress
Viết LạiEngine Trên
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
viết lại cơ sở /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Quy tắc viết lại . /index.php [L]
# HẾT WordPress
Tôi đang làm gì ở đây?