Error when addressing

0

I'm circling but I can not find the error: I have wordpress installed in home root. I made a redirection so that from the web it looks like domain.com. Could you help me?

mi (.htaccess) located in public html:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?dominio.com$
RewriteCond %{REQUEST_URI} !^/home/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Cambiar 'subdirectory' por el nombre del subdirectorio que quiere usar
RewriteRule ^(.*)$ /home/$1
RewriteCond %{HTTP_HOST} ^(www.)?dominio.com$
RewriteRule ^(/)?$ home/index.php [L]

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://dominio.com/$1 [R=301,L,QSA]
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$"> Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>

RewriteEngine on
RewriteCond %{HTTP_HOST} ^dominio.com.ar$ [OR]
RewriteCond %{HTTP_HOST} ^www.dominio.com.ar$ 
RewriteRule ^(.*)$ https://dominio.com/$1 [R=301]

mi (.htaccess) located at home:

# BEGIN All In One WP Security
#AIOWPS_BASIC_HTACCESS_RULES_START
<Files .htaccess>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
ServerSignature Off
LimitRequestBody 10240000
<Files wp-config.php>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
</Files>
#AIOWPS_BASIC_HTACCESS_RULES_END
# END All In One WP Security

# BEGIN rlrssslReallySimpleSSL rsssl_version[3.1.2]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL

# BEGIN WordPress
<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

 RewriteEngine on

 RewriteCond %{HTTP_HOST} ^www.dominio.com [NC]
 RewriteRule ^(.*)$ https://dominio.com/$1 [L,R=301]
    
asked by Jennifer 27.11.2018 в 17:43
source

1 answer

1

The problem is in the order of the rewriting rules. The ones Wordpress uses by default "catch" all the requests before they reach the ones you put at the end.

A good order for what you want to do could be the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.dominio.com [NC]
RewriteRule ^(.*)$ https://dominio.com/$1 [L,R=301]
</IfModule>

# BEGIN WordPress
<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

This way, it first tests if the address has www or not and then passes under the control of WP.

Additionally, it is always good practice to put these types of configurations inside the corresponding IfModule block.

    
answered by 03.12.2018 / 21:30
source