amazon-web-services - 在 AWS lightail LAMP 中向 htaccess 文件添加子域
问题描述
我正在使用 AWS Lightsail LAMP 实例来托管该站点。我想为其添加子域。经过大量搜索后,我无法自己修复它,需要一些帮助。
细节:
根域 --> 英文 -https://www.example.site/
我想将其他语言添加为子域。
子域 - 法语 -https://fr.example.site/
子域 - 德语 -https://de.example.site/
我已经完成了 vhost 配置并且 apache2 服务器从https://fr.example.site/和https://de.example.site/成功地提供了测试页面
但是,当我使用 htaccess 部署实际应用程序时,根域工作正常,但子域导致以下错误
fr.example.site is currently unable to handle this request.
HTTP ERROR 500
我的 htaccess 规则存在一些问题。
这是我现有的 htaccess 内容。
Options -MultiViews
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
RewriteRule ^index.html$ index.php
RewriteRule ^(.*)-result.html$ result.php
RewriteRule ^2-letter-words-with-(.*).html$ twoletter.php
RewriteRule ^3-letter-words-with-(.*).html$ threeletter.php
RewriteRule ^words-starting-in-(.*).html$ wordstartedwith.php
我想为子域 fr 和 de 添加规则,以便从以下目录提供内容。
https://www.example.site/ --> /home/bitnami/htdocs/
https://fr.example.site/ --> /home/bitnami/htdocs/fr
https://de.example.site / --> /home/bitnami/htdocs/de
任何指针都会有很大帮助。
解决方案
使用您显示的示例,您能否尝试以下操作。请确保在测试 URL 之前清除浏览器缓存。
##For base site Rules.
RewriteCond %{HTTP_HOST} ^(?:www\.)example\.site [NC]
RewriteCond ^/?$
RewriteRule ^ home/bitnami/htdocs/ [L]
##For fr site Rules.
RewriteCond %{HTTP_HOST} fr\.example\.com [NC]
RewriteCond ^/?$
RewriteRule ^ home/bitnami/htdocs/fr [L]
##For de site Rules.
RewriteCond %{HTTP_HOST} de\.example\.com [NC]
RewriteCond ^/?$
RewriteRule ^ home/bitnami/htdocs/de [L]
推荐阅读
- exchangewebservices - 读取 Exchange 快速传输流的任何 API
- java - gradle构建时未生成Clojure(clara规则)文件
- ada - GtkAda 简单窗口:找不到 pixbuf 加载程序或 mime 数据库
- r - 将“table1”-table 转换为 pdf 友好格式
- c# - 代码优先迁移中的 EFCore AlterColumn MaxLength
- amazon-web-services - Cloudformation:UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS 卡住问题
- r - lm.fit(x,y,offset = offset,singular.ok =singular.ok,...)中的错误:重复测量方差分析中的 0(非 NA)案例
- python - 尝试添加外部用户但收到以下错误(错误 403:org_Internal)
- python - (x,) 在 NumPy 形状中表示什么?
- javascript - 有没有办法让我的音乐不和谐机器人保存音量设置?