niemen Posted June 22, 2020 Posted June 22, 2020 (edited) Hello My ultimate goal is to redirect a single Wordpress post like https://mysite.com/test-page/ to https://america.mysite.com/test-page/ (= same url but with a subdomain included) After adding the respective subdomain through CPanel and redirecting it with Yoast SEO Plugin, it at least changes to this desired subdomain within the URL bar. However, first I received a SSL certificate error and second, now I receive a redirect loop error after adding that subdomain again through CPanel. I would really like to know if this whole procedure is feasible and if you have other solutions to offer. Best RegardsNiemen Edited June 22, 2020 by niemen
Krydos Posted June 22, 2020 Posted June 22, 2020 Try this RewriteEngine on RewriteCond %{HTTP_HOST} !america.mysite.com RewriteRule /test-page/ https://america.mysite.com/test-page/
niemen Posted June 22, 2020 Author Posted June 22, 2020 Hello I appreciate your reply, however, there must still be an issue. Testing my site on webpagetest.org outputs the following: (Test Error: net::ERR_CERT_COMMON_NAME_INVALID)(Error: 404) But please correct the following steps in order to find the cause:1. Creating a subdomain in CPanel 2. Adding your code to the .htaccess file in public_html (not the folder of the subdomain) <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !mario-kart.billigerkaufen.com RewriteRule /neue-tipps-tricks/ https://mario-kart.billigerkaufen.com/neue-tipps-tricks/ </IfModule> ... ... (other code) 3. Redirecting through Yoast SEO which has a function to add 301 permanent redirects:https://billigerkaufen.com/neue-tipps-tricks/ to https://mario-kart.billigerkaufen.com/neue-tipps-tricks/ Best RegardsNiemen
wolstech Posted June 22, 2020 Posted June 22, 2020 First, the forced SSL prevents the server from getting a certificate. There needs to be an exception so the .well-known folder can be accessed via plain http. I don’t have that code handy at the moment since I’m on mobile, so the crude fix is to just delete these two lines: RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}{REQUEST_URI} [L,R=301] ...and wait for autossl. That SSL error is normal when the cert is either missing or doesn’t cover the domain you’re using it on. Note that a cert for example.com will NOT cover sub.example.com. AutoSSL should get you the right cert if you let it, but it probably failed because you forced SSL. Also, it can take time to work, it’s not instant.
Krydos Posted June 23, 2020 Posted June 23, 2020 WordpressBefore we go much further I need to give you the standard wordpress lecture. Wordpress causes insane amounts of load. Your site has only gotten 164 MB of traffic over the last week and already it's topping the charts on load for the server This is very common for wordpress. Wordpress is the #1 cause of high load suspensions. If your cpu or memory bars reaches 100 it means you could be suspended at any minute. If your site can reach #1 cpu on a server that hosts thousands of other accounts with only 164 MB traffic for a whole week imagine what the load will be when you actually start getting traffic. For comparison, the #1 bandwidth account for the week transferred 12 GB of traffic, that's 73 times as much traffic as your site, and your site used 6 times as much cpu as his. Just some numbers to consider. We always strongly recommend people don't use wordpress for this and many other reasons. You can keep an eye on your load graph at this url https://tommy.heliohost.org:2083/frontend/paper_lantern/load/index.live.php
wolstech Posted June 23, 2020 Posted June 23, 2020 We always strongly recommend people don't use wordpress for this and many other reasons. Most notably, its a security disaster. WP gets hacked regularly, unlike just about every other CMS in existence. Once hacked, the hacker usually either sends a bunch of spam or sets up phishing. Either way, WP getting hacked will usually earn your account a permanent suspension and loss of all data. WP is the #1 cause of accidental suspensions here at HelioHost. If you need an alternative, Joomla (and more recently Ghost) have been quite popular around here and they don't suffer these same issues.
Krydos Posted June 23, 2020 Posted June 23, 2020 I'm curious how something like this would work for our wordpress people https://hostadvice.com/how-to/how-to-convert-a-wordpress-site-to-a-static-html-website/ You could then put a 403 forbidden on the dynamic, slow, buggy wordpress site unless you were actually adding new content, and let all the traffic go to the static site that can't be hacked, is much faster, and causes basically no load.
niemen Posted June 23, 2020 Author Posted June 23, 2020 (edited) HelloFirst i would like to apologise for the server load, however, this is just a temporary thing. I have been testing my web page A LOT during Corona for a month now or so. In the meantime I have compressed my pages to roughly 150 kb (with images included), reduced http requests to about 16, and it is normally running in conjunction with Cloudflare (not now). It results in GTMetrix values of 100 % (PageSpeed) and 96 % (YSlow). So I hope that my roughly 100 visitors a month will not hurt you in the long term after everything has been completed. Actually, I already achieved 90% of what I wanted during the last month - this subdomain redirect is one of the last steps on my To Do List. Back to my issue: This is the current error I receive If I understood you correctly yesterday, I had to remove RewriteCond %{HTTPS} offRewriteRule ^(.*)$ https://%{HTTP_HOST}{REQUEST_URI} [L,R=301] which I did. In the meantime my .htaccess file looks like this (I found great code on the internet to use the above mentioned parameters, however, leave .well-know untouched) <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # force https:// for all except some selected URLs RewriteCond %{HTTPS} off RewriteCond %{THE_REQUEST} !/.well-known/ [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # force http:// for selected URLs RewriteCond %{HTTPS} on RewriteCond %{THE_REQUEST} /.well-known/ [NC] RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !mario-kart.billigerkaufen.com RewriteRule /neue-tipps-tricks/ https://mario-kart.billigerkaufen.com/neue-tipps-tricks/ </IfModule> Best Regards Niemen Edited June 23, 2020 by niemen
wolstech Posted June 23, 2020 Posted June 23, 2020 Rename .htaccess so its ignored and see if the 500 error goes away. If so, its a syntax error or unsupported option in .htaccess. Also, remove the "force http" section, the services that need the stuff in .well-known will use whatever protocol they please and tend to hate being forced onto a specific protocol. AutoSSL likes HTTP, but there's also stuff that likes HTTPS in there. Let the services themselves use what they want, don't force anything. The size of your page doesn't matter since we don't monitor bandwidth unlike other web hosts. It's the amount of CPU and RAM on the server that we monitor, and WP is simply the worst at both of these. You're topping our charts with just your test traffic, and CF won't fix that because dynamic pages are not cached by CF. Other hosts generally monitor bandwidth instead of resource use, because it's easily quantified and they have tons of servers that they can pay for with money from paid hosting. Since we don't have paid services and also don't pay for bandwidth (our provider gives us unlimited traffic), we control the server resources instead so we can pack more accounts into a single server. Some other things to consider: SSL is increases load, as does compression (if you use it). The only real fix is to not use WP, but not using SSL (from a security standpoint it's pointless unless your site collects information of some sort anyway) and turning off any sort of compression you have enabled might help a little. Krydos's idea looks promising too. Convert the public site to static HTML and only use the WP install to generate new static pages when you change content. Static pages cause virtually no resource use at all. Once live, that site will end up suspended if the numbers above continue.
niemen Posted June 23, 2020 Author Posted June 23, 2020 (edited) Hello I appreciate your lengthy respond. I cannot promise you to switch to an alternative of Wordpress because I invested hours and days into it. But I can promise you to have a look at your suggestion in the next few days and to analyse which potential Plugins cause this CPU an RAM usage. I have fallen in love with HelioHost, so I want to stay here forever. Back to the Issue: Removing the "force http" section leads to this error: And renaming .htaccess leads to this error in turn: I would like you to remember that my Yoast SEO Plugin is also in use for the purpose of redirecting to this subdomain (see my first or second post) Furthermore, here you can find my current .htaccess file (without http force now): <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !mario-kart.billigerkaufen.com RewriteRule /neue-tipps-tricks/ https://mario-kart.billigerkaufen.com/neue-tipps-tricks/ </IfModule> # This file was updated by Duplicator on 2018-08-24 21:01:57. See .htaccess.orig for the original .htaccess file. # Please note that other plugins and resources write to this file. If the time-stamp above is different # than the current time-stamp on the file system then another resource has updated this file. # Duplicator only writes to this file once during the install process while running the installer.php file. # BEGIN # This file was updated by Duplicator on 2018-08-24 21:01:57. See .htaccess.orig for the original .htaccess file. # Please note that other plugins and resources write to this file. If the time-stamp above is different # than the current time-stamp on the file system then another resource has updated this file. # Duplicator only writes to this file once during the install process while running the installer.php file. # BEGIN W3TC Browser Cache <IfModule mod_mime.c> AddType text/css .css AddType text/x-component .htc AddType application/x-javascript .js AddType application/javascript .js2 AddType text/javascript .js3 AddType text/x-js .js4 AddType text/html .html .htm AddType text/richtext .rtf .rtx AddType text/plain .txt AddType text/xsd .xsd AddType text/xsl .xsl AddType text/xml .xml AddType video/asf .asf .asx .wax .wmv .wmx AddType video/avi .avi AddType image/bmp .bmp AddType application/java .class AddType video/divx .divx AddType application/msword .doc .docx AddType application/vnd.ms-fontobject .eot AddType application/x-msdownload .exe AddType image/gif .gif AddType application/x-gzip .gz .gzip AddType image/x-icon .ico AddType image/jpeg .jpg .jpeg .jpe AddType image/webp .webp AddType application/json .json AddType application/vnd.ms-access .mdb AddType audio/midi .mid .midi AddType video/quicktime .mov .qt AddType audio/mpeg .mp3 .m4a AddType video/mp4 .mp4 .m4v AddType video/mpeg .mpeg .mpg .mpe AddType video/webm .webm AddType application/vnd.ms-project .mpp AddType application/x-font-otf .otf AddType application/vnd.ms-opentype ._otf AddType application/vnd.oasis.opendocument.database .odb AddType application/vnd.oasis.opendocument.chart .odc AddType application/vnd.oasis.opendocument.formula .odf AddType application/vnd.oasis.opendocument.graphics .odg AddType application/vnd.oasis.opendocument.presentation .odp AddType application/vnd.oasis.opendocument.spreadsheet .ods AddType application/vnd.oasis.opendocument.text .odt AddType audio/ogg .ogg AddType application/pdf .pdf AddType image/png .png AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx AddType audio/x-realaudio .ra .ram AddType image/svg+xml .svg .svgz AddType application/x-shockwave-flash .swf AddType application/x-tar .tar AddType image/tiff .tif .tiff AddType application/x-font-ttf .ttf .ttc AddType application/vnd.ms-opentype ._ttf AddType audio/wav .wav AddType audio/wma .wma AddType application/vnd.ms-write .wri AddType application/font-woff .woff AddType application/font-woff2 .woff2 AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw AddType application/zip .zip </IfModule> <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css A31536000 ExpiresByType text/x-component A31536000 ExpiresByType application/x-javascript A31536000 ExpiresByType application/javascript A31536000 ExpiresByType text/javascript A31536000 ExpiresByType text/x-js A31536000 ExpiresByType text/html A3600 ExpiresByType text/richtext A3600 ExpiresByType text/plain A3600 ExpiresByType text/xsd A3600 ExpiresByType text/xsl A3600 ExpiresByType text/xml A3600 ExpiresByType video/asf A31536000 ExpiresByType video/avi A31536000 ExpiresByType image/bmp A31536000 ExpiresByType application/java A31536000 ExpiresByType video/divx A31536000 ExpiresByType application/msword A31536000 ExpiresByType application/vnd.ms-fontobject A31536000 ExpiresByType application/x-msdownload A31536000 ExpiresByType image/gif A31536000 ExpiresByType application/x-gzip A31536000 ExpiresByType image/x-icon A31536000 ExpiresByType image/jpeg A31536000 ExpiresByType image/webp A31536000 ExpiresByType application/json A31536000 ExpiresByType application/vnd.ms-access A31536000 ExpiresByType audio/midi A31536000 ExpiresByType video/quicktime A31536000 ExpiresByType audio/mpeg A31536000 ExpiresByType video/mp4 A31536000 ExpiresByType video/mpeg A31536000 ExpiresByType video/webm A31536000 ExpiresByType application/vnd.ms-project A31536000 ExpiresByType application/x-font-otf A31536000 ExpiresByType application/vnd.ms-opentype A31536000 ExpiresByType application/vnd.oasis.opendocument.database A31536000 ExpiresByType application/vnd.oasis.opendocument.chart A31536000 ExpiresByType application/vnd.oasis.opendocument.formula A31536000 ExpiresByType application/vnd.oasis.opendocument.graphics A31536000 ExpiresByType application/vnd.oasis.opendocument.presentation A31536000 ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000 ExpiresByType application/vnd.oasis.opendocument.text A31536000 ExpiresByType audio/ogg A31536000 ExpiresByType application/pdf A31536000 ExpiresByType image/png A31536000 ExpiresByType application/vnd.ms-powerpoint A31536000 ExpiresByType audio/x-realaudio A31536000 ExpiresByType image/svg+xml A31536000 ExpiresByType application/x-shockwave-flash A31536000 ExpiresByType application/x-tar A31536000 ExpiresByType image/tiff A31536000 ExpiresByType application/x-font-ttf A31536000 ExpiresByType application/vnd.ms-opentype A31536000 ExpiresByType audio/wav A31536000 ExpiresByType audio/wma A31536000 ExpiresByType application/vnd.ms-write A31536000 ExpiresByType application/font-woff A31536000 ExpiresByType application/font-woff2 A31536000 ExpiresByType application/vnd.ms-excel A31536000 ExpiresByType application/zip A31536000 </IfModule> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon application/json application/vnd.ms-access video/webm application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel <IfModule mod_mime.c> # DEFLATE by extension AddOutputFilter DEFLATE js css htm html xml </IfModule> </IfModule> <FilesMatch "\.(css|htc|less|js|js2|js3|js4|CSS|HTC|LESS|JS|JS2|JS3|JS4)$"> FileETag MTime Size <IfModule mod_headers.c> Header set Pragma "public" Header append Cache-Control "public" Header set X-Powered-By "W3 Total Cache/0.14.2" </IfModule> </FilesMatch> <FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|TXT|XSD|XSL|XML)$"> FileETag MTime Size <IfModule mod_headers.c> Header set Pragma "public" Header append Cache-Control "public" Header set X-Powered-By "W3 Total Cache/0.14.2" </IfModule> </FilesMatch> <FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|webm|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|WEBP|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|WEBM|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|_TTF|WAV|WMA|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW|ZIP)$"> FileETag MTime Size <IfModule mod_headers.c> Header set Pragma "public" Header append Cache-Control "public" Header set X-Powered-By "W3 Total Cache/0.14.2" </IfModule> </FilesMatch> <FilesMatch "\.(bmp|class|doc|docx|eot|exe|ico|json|mdb|webm|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|BMP|CLASS|DOC|DOCX|EOT|EXE|ICO|JSON|MDB|WEBM|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|POT|PPS|PPT|PPTX|SVG|SVGZ|SWF|TIF|TIFF|TTF|TTC|_TTF|WAV|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW)$"> <IfModule mod_headers.c> Header unset Last-Modified </IfModule> </FilesMatch> <IfModule mod_headers.c> Header set Referrer-Policy "" </IfModule> # END W3TC Browser Cache # BEGIN W3TC Page Cache core <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} =on RewriteRule .* - [E=W3TC_SSL:_ssl] RewriteCond %{SERVER_PORT} =443 RewriteRule .* - [E=W3TC_SSL:_ssl] RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC] RewriteRule .* - [E=W3TC_SSL:_ssl] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=W3TC_ENC:_gzip] RewriteCond %{HTTP_COOKIE} w3tc_preview [NC] RewriteRule .* - [E=W3TC_PREVIEW:_preview] RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{QUERY_STRING} ="" RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] RewriteCond %{REQUEST_URI} \/$ RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L] RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{QUERY_STRING} ="" RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.xml%{ENV:W3TC_ENC}" -f RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.xml%{ENV:W3TC_ENC}" [L] </IfModule> # END W3TC Page Cache core # 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 # END # BEGIN W3TC Page Cache core <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=W3TC_ENC:_gzip] RewriteCond %{HTTP_COOKIE} w3tc_preview [NC] RewriteRule .* - [E=W3TC_PREVIEW:_preview] RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{QUERY_STRING} ="" RewriteCond %{REQUEST_URI} \/$ RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L] </IfModule> # END W3TC Page Cache core # 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 Best Regards Niemen Edited June 23, 2020 by niemen
Krydos Posted June 23, 2020 Posted June 23, 2020 You get a 404 because you're redirecting to something that doesn't exist. There is nothing at https://mario-kart.billigerkaufen.com/
wolstech Posted June 23, 2020 Posted June 23, 2020 I would start by removing all these redirects, optimizaion, and SEO nonsense, and just get the site to work first. Remove the Yoast and caching stuff from WP, and rename your .htaccess file so its ignored entirely. Then just get the site to work when visited. Don't worry about SSL or caching or SEO or anything else. Until your domain can actually display your content, those other things are pointless. Also, I suspect the docroot for the subdomain is wrong. If this is supposed to do what I think it's supposed to, the subdomain needs to have the same docroot as its parent domain (i.e. the subdomain is just for show and doesn't actually go anywhere different from the actual domain). While this sort of setup is possible, it is also entirely pointless (some snake-oil SEO sites say this is a good idea, but I've never seen it actually matter, and it adds needless complexity).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now