我使用.htaccess重定向某些地址或避免一些要重定向的地址。基本上,除了我指定的某些地址之外,我已经将所有内容都重定向到另一个域。因此,example.com/NormalPage将被重定向到example.dev/NormalPage,但example.com/ThatPage不会被重定向,如果有人打开example.dev/ThatPage,它将被重定向到example.com/ThatPage。一些地址也可以从这两个域访问。例如,example.com和example.dev不会被重定向,两者显示的内容是相同的。
现在,由于这种重定向,wp-admin和其他WordPress文件系统可能(不确定)被重定向。我的主要领域是example.com,而不是example.dev,但是现在我必须使用example.dev (这是新域)发布注释或编辑页面。不应该发生这种事。
我希望这两个领域能够张贴和编辑网页和文字。现在,当我想编辑一个页面或贴一个便条时,当我按publish按钮或update按钮时,它会告诉我我离线了,或者当我想为一个帖子选择一个类别时,它不会列出它们。
这是我当前的.httaccess文件。你能告诉我怎么解决吗?
# Prevent rewritten requests (to the WP front-controller) from being redirected
RewriteCond %{ENV:REDIRECT_STATUS} .
RewriteRule ^ - [L]
# The TARGET_DOMAIN environment variable holds the desired target domain (if any)
# - for the requested URL
# eg. "example.com" or "example.dev" or empty for no redirect / accessible from both.
# Set the "default" target domain
# - Any URLs not listed below will redirect to this domain
RewriteRule ^ - [E=TARGET_DOMAIN:example.dev]
# URLs that should be redirected to (or remain at) the other domain
RewriteCond %{REQUEST_URI} ^/bio [OR]
RewriteCond %{REQUEST_URI} ^/computing [OR]
RewriteCond %{REQUEST_URI} ^/contact [OR]
RewriteCond %{REQUEST_URI} ^/donate [OR]
RewriteCond %{REQUEST_URI} ^/encrypt [OR]
RewriteCond %{REQUEST_URI} ^/genderless-pronouns [OR]
RewriteCond %{REQUEST_URI} ^/gnu-linux-controversy [OR]
RewriteCond %{REQUEST_URI} ^/keys [OR]
RewriteCond %{REQUEST_URI} ^/legal [OR]
RewriteCond %{REQUEST_URI} ^/pages [OR]
RewriteCond %{REQUEST_URI} ^/readings [OR]
RewriteCond %{REQUEST_URI} ^/now
RewriteRule ^ - [E=TARGET_DOMAIN:example.com]
# URLs that should not be redirected - accessible from both domains
# - Sets TARGET_DOMAIN to empty string (ie. no target domain)
RewriteCond %{REQUEST_URI} ^/login [OR]
RewriteCond %{REQUEST_URI} ^/admin [OR]
RewriteCond %{REQUEST_URI} ^/wp-admin [OR]
RewriteCond %{REQUEST_URI} ^/wp-login [OR]
RewriteCond %{REQUEST_URI} ^/wp-admin [OR]
RewriteCond %{REQUEST_URI} ^/wp-content [OR]
RewriteCond %{REQUEST_URI} ^/wp-includes [OR]
RewriteCond %{REQUEST_URI} \.(php|css|js|jpg|gif|webp)$ [OR,NC]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [E=TARGET_DOMAIN]
# Redirect to the desired TARGET_DOMAIN (if any)
# - if not already at the TARGET_DOMAIN
RewriteCond %{ENV:TARGET_DOMAIN} .
RewriteCond %{HTTP_HOST}@@%{ENV:TARGET_DOMAIN} !^([a-z0-9.-]+)@@\1$
RewriteRule ^ https://%{ENV:TARGET_DOMAIN}%{REQUEST_URI} [R=302,L]
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
ErrorDocument 503 /503.html发布于 2020-11-10 15:00:52
我已将所有内容重定向到另一个域,但我指定的某些地址除外。
这当然是问题所在。还需要将额外的HTTP请求添加到以下规则块中,以防止用于example.com的请求被重定向到example.dev。
不应该被重定向的URLs -从两个域#访问--将TARGET_DOMAIN设置为空字符串(即。(没有目标域) RewriteCond %{REQUEST_URI} ^/登录RewriteCond %{REQUEST_URI} ^^/ RewriteCond %{REQUEST_URI} ^/wp-管理RewriteCond %{REQUEST_URI} ^/wp-登录RewriteCond %{REQUEST_URI} ^/wp-管理RewriteCond %{REQUEST_URI} ^/wp-content RewriteCond %{REQUEST_URI} ^/wp-包括#在此添加更多条件.RewriteCond %{REQUEST_URI} .(php/js/jpg/gif\webp)$ RewriteCond %{REQUEST_FILENAME} -f RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^-
但是,为了确定要排除的这些附加URL,您需要检查在浏览器中发出的HTTP请求。其中一些请求可能是由JavaScript/AJAX触发的。我不知道这些请求会是什么不幸,但它可能会有所不同,取决于插件等。
或者,您可以更改您的方法,而不是将“一切”从example.com重定向到example.dev (默认操作),而只是重定向选择URL。例如:
example.comexample.dev在.htaccess中:
# Prevent rewritten requests (to the WP front-controller) from being redirected
RewriteCond %{ENV:REDIRECT_STATUS} .
RewriteRule ^ - [L]
# The TARGET_DOMAIN environment variable holds the desired target domain (if any)
# - for the requested URL
# eg. "example.com" or "example.dev" or empty for no redirect / accessible from both.
# The "default" is NO REDIRECT
# URLs that should be redirected to (or remain at) example.com
RewriteCond %{REQUEST_URI} ^/bio [OR]
RewriteCond %{REQUEST_URI} ^/computing [OR]
RewriteCond %{REQUEST_URI} ^/contact [OR]
RewriteCond %{REQUEST_URI} ^/donate [OR]
RewriteCond %{REQUEST_URI} ^/encrypt [OR]
RewriteCond %{REQUEST_URI} ^/genderless-pronouns [OR]
RewriteCond %{REQUEST_URI} ^/gnu-linux-controversy [OR]
RewriteCond %{REQUEST_URI} ^/keys [OR]
RewriteCond %{REQUEST_URI} ^/legal [OR]
RewriteCond %{REQUEST_URI} ^/pages [OR]
RewriteCond %{REQUEST_URI} ^/readings [OR]
RewriteCond %{REQUEST_URI} ^/now
RewriteRule ^ - [E=TARGET_DOMAIN:example.com,S=1]
# URLs that should be redirected to (or remain at) example.dev
RewriteCond %{REQUEST_URI} ^/example-one [OR]
RewriteCond %{REQUEST_URI} ^/example-two [OR]
RewriteCond %{REQUEST_URI} ^/example-three
RewriteRule ^ - [E=TARGET_DOMAIN:example.dev]
# Redirect to the desired TARGET_DOMAIN (if any)
# - if not already at the TARGET_DOMAIN
RewriteCond %{ENV:TARGET_DOMAIN} .
RewriteCond %{HTTP_HOST}@@%{ENV:TARGET_DOMAIN} !^([a-z0-9.-]+)@@\1$
RewriteRule ^ https://%{ENV:TARGET_DOMAIN}%{REQUEST_URI} [R=302,L]
# BEGIN WordPress
# :https://wordpress.stackexchange.com/questions/377841
复制相似问题