Query strings are unnecessary for static files like JS and CSS because they do not process the parameters passed to them. WordPress put them there so that when you update WordPress version the old file will not be cached and you immediately get the updated version.
To find out if your site is suffering from unnecessary query strings from static resources. Go have your site test out at pingdom. From the test, my default WordPress theme is having a bad score of “E”.
Remove static resources query strings
There is WordPress plugin to fix this but I dislike the fact that there are so many badly written plugins that will damage my WordPress site. Therefore I prefer to fix it the PHP way.
To fix it, go to the functions.php file within the folder of your theme and add the following codes at the end of the file. What the codes do is that it is splitting the URL using “?” as the delimiter and then choose the first part of it.
In order to setup Cloudflare flexible SSL for your WordPress site, you’ll need to move your domain name server to Cloudflare. Login to your Cloudflare, at the top menu, choose crypto, then change SSL settings to flexible.
At the top menu, choose page rules. Add a page rule to always use HTTPS for http://www.oofnivek.com/*
Take note that the URL is HTTP and not HTTPS. This is because my web server is actually serving pages using HTTP and not https. Cloudflare is the one serving my pages using https acting like a proxy between you and my server.
Install WordPress plugin
Other than the configuration in Cloudflare, we need to install WordPress HTTPS (SSL) plugin. Without this plugin, loading the page will cause mixed content error and warnings. Once installed and activated, set the value for “proxy” to yes. If properly configured, it should show secure now next to the address bar.
I assume you had already installed Apache into your Ubuntu elastic compute cloud ( EC2 ) instance. If you had not, then read my test Cloudflare DNS blog post, I had written about installing Apache. The entire guide below is using Ubuntu 16.04.
Configure Rewrite Module
This step is optional if you do not mind seeing “index.php” with query strings suffix after it. To remove it, you’ll need to configure the rewrite module in Apache. Go to /etc/apache2/sites-available/ and edit the file 000-default.conf and add the following codes in between the “VirtualHost” tag. After that type in the following commands to enable rewrite module.
Options Indexes FollowSymLinks MultiViews
Require all granted
sudo a2enmod rewrite
sudo service apache2 restart
Install MySQL server
To install MySQL server, type in the following commands in your Ubuntu terminal. During installation, it will prompt you for the root password. Type in your desired root password and repeat the same password in the next screen.
Next type in mysql_secure_installation. You will be prompted with a series of questions, you can answer accordingly as per my example. Create a database for WordPress use with the commands below. In my example, my database root user password is “password”. Replace the password with the password you entered earlier when you install MySQL server.
Would you like to setup VALIDATE PASSWORD plugin? : n
Change the password for root ? : n
Remove anonymous users? : y
Disallow root login remotely? : y
Remove test database and access to it? : y
Reload privilege tables now? : y
mysql -uroot -ppassword -e 'create database wordpress'
Creating a database for WordPress by executing the MySQL statement with your password reveal in plain text will cause a warning. To suppress Bash MySQL warning you will need to store the password in the encrypted “.mylogin.cnf” file.
To install PHP, type in the following commands. Once completed, to test if you had successfully installed PHP, open your web browser and go to “http://18.104.22.168/info.php”. Your IP address will be different from mine, replace the IP address with yours.
If you are unsure of your IP address, you can type in the curl command below to check. Make sure that you configure security group to allow inbound HTTP traffic.
sudo apt-get install php php-mysql libapache2-mod-php php-curl -y
echo '<?php phpinfo(); ?>' | sudo tee -a /var/www/html/info.php
Ubuntu Install WordPress
To install WordPress, type in the following commands. Once completed, go to “http://22.214.171.124/index.php”. Your IP address will be different from mine, replace the IP address with yours. You should see the WordPress setup config page. Follow through the setup wizard to complete the WordPress setup.
tar -xzvf latest.tar.gz
sudo mv * /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/