Forum Moderators: open
www, and by looking first for non-existent directories such as; /blog/ /wp/ /wordpress/ http://www.example.com/blog/ https and www http://www.examplecom.myotherdomain.org/blog/ myotherdomain.org is my wordpress site on the same cPanel account, but it does not have the directory /blog/ either, and never has. How can this happen?You don't happen to have nested folders below the root public_html directory that contain the other domains do you? That is what the setup sounds like and in that case you might have separate .htaccess files under the main rewrites. If that is the case you may only need to add the 301 rules to those subsequent .htaccess files because Mod_Rewrite rules are not inherited when folders have additional .htaccess files.
examplecom.myotherdomain.org Document root: /example.com
Redirection: http://examplecom.myotherdomain.org/(?i)([a-z0-9]{2000,}) RewriteEngine On
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # Redirecting all root 404 traffic to the root folder
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [R,L] # 7G:[CORE]
ServerSignature Off
RewriteEngine On
RewriteBase / # Contabo scan bot
deny from 66.94.96.0/19
I would take a look at your access logs because CPanel defaults to a 302 and not a 301 for rewrites.
66.94.126.xx - - [07/Dec/2021:xxxxx] "GET /wp/ HTTP/1.1" 301 707 "-" "Mozilla/5.0 (Linux; Android 5.1.1; SM-J111F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36"
66.94.126.xx - - [07/Dec/2021:xxxxx] "GET /wp/ HTTP/1.1" 302 683 "http://examplecom.myotherdomain.org/wp/" "Mozilla/5.0 (Linux; Android 5.1.1; SM-J111F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36" Why are 404 pages sent to the root directory instead of using a 404 error page?
WP can be in any directory and use the root .htaccess file because it will write its own .htaccess snippet as long as the Admin > Settings > General are set up with the correct WP URL and Site URL and you have an index.php file in the root directory. Again, if it is not broke, don't fix it.