El servidor (WordPress) redirige los archivos que se supone que no deben hacerlo (usando htaccess)
Utilizo .htaccess
para redirigir algunas direcciones o evitar que algunas direcciones sean redirigidas. Básicamente, tengo todas las cosas redirigidas a otro dominio, excepto ciertas direcciones que especifiqué. Por example.com/NormalPage
lo tanto , será redirigido a, example.dev/NormalPage
pero example.com/ThatPage
no será redirigido, y si alguien abre example.dev/ThatPage
, será redirigido a example.com/ThatPage
. Algunas direcciones también son accesibles desde ambos dominios. Por ejemplo, example.com
y example.dev
no se redirige y ambos muestran lo mismo.
Ahora, debido a esta redirección, wp-admin
y otros sistemas de archivos de WordPress probablemente (no estoy seguro) serán redirigidos. Mi dominio principal example.com
no lo es, example.dev
pero ahora tengo que publicar notas o editar páginas usando example.dev
(que es el nuevo dominio). Eso no debería suceder.
Quiero que ambos dominios puedan publicar y editar páginas y escritos. Ahora, cuando quiero editar una página o publicar una nota, cuando presiono el publish
botón o el update
botón, me dice que estoy desconectado o cuando quiero seleccionar una categoría para una publicación, no los enumera.
Aquí está mi .httaccess
archivo actual . ¿Puedes decirme cómo solucionar esto?
# 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.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
ErrorDocument 503 /503.html
Respuestas
Tengo todas las cosas redirigidas a otro dominio excepto ciertas direcciones que especifiqué
Este es sin duda el problema aquí. Habrá solicitudes HTTP adicionales que deberán agregarse al siguiente bloque de reglas para evitar solicitudes destinadas a example.com
ser redirigidas example.dev
.
# 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] # Add more conditions here... RewriteCond %{REQUEST_URI} \.(php|css|js|jpg|gif|webp)$ [OR,NC] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [E=TARGET_DOMAIN]
Sin embargo, para determinar estas URL adicionales para excluir, deberá examinar las solicitudes HTTP que se realizan en el navegador. Algunas de estas solicitudes pueden ser activadas por JavaScript / AJAX. Desafortunadamente, no sé cuáles serían estas solicitudes, pero posiblemente podría variar según los complementos, etc.
Alternativamente, cambia su enfoque y en lugar de redirigir "todo" de example.com
a example.dev
(la acción predeterminada), solo redirige las URL seleccionadas. Por ejemplo:
- Algunas URL de página redireccionan a (o permanecen en)
example.com
- Algunas URL de página redireccionan a (o permanecen en)
example.dev
- Cualquier URL no especificada no redirige.
En .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
# :