php - 如果请求 wp-admin,Apache 重写规则以停止重定向
问题描述
我在谷歌云上有一个带有 bitnami 的 apache 配置文件。我添加了一条从非 www aka example.com 重定向到www.example.com的规则。但是,我想在 /wp-admin/ 目录不重定向但留在 example.com 的规则中例外。
更多示例
example.com/launch.html -> www.example.com/launch.html
example.com/wp-admin/plugins -> example.com/wp-admin/plugins(保持不变)
Apache conf 文件原样
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
解决方案
推荐阅读
- android - Android Studio 在布局预览中不显示状态栏、导航栏和默认工具栏
- python - 打开 Dask 包的客户端仪表板时出错
- typescript - 如何在 TypeScript 类型声明中使用动态类?
- python - 如何在代码更新期间保持 Azure Function 可用?
- javascript - 将 web worker 捆绑为带有单个文件 webpack 输出的 npm 包的组成部分
- amazon-web-services - 如何使用 gsutil 通过 http 链接从谷歌云存储下载到 AWS 实例或 s3 存储桶?
- html - 为什么我的
变换时元素消失:旋转(45度)?
- android - 如何使用xml将属性从控件传递到android中的drawable?
- php - 从感谢页面打印产品选项苦苦挣扎
- javascript - 会话存储值为空,而我已在另一个 JS 文件中为此会话存储赋值