If you install WordPress on Lightsail, you will have to set up a variety of settings initially. Unlike Naver Blog, you need to set up additional settings by entering commands on the server, and among them, .htaccess is important because you can set up redirects.
However, if it is in the initial setting, it does not work properly even if you add a redirect to .htaccess. Because of this, I looked at foreign community documents to find a solution, and it is because the AllowOverride directive is basically set to Nono and does not allow it.
To put it more simply, since .htaccess usage is set to not be allowed by default, if you enable this part, it will work properly.
Please note that this part is based on Lightsail WordPress Bitnami and may differ in other environments. Then, let’s look at an example of setting up a redirect and how to allow it to work.
Table of Contents
IP address redirect
When you connect a domain to WordPress, there are three types of documents recognized: those with and without www. and IP addresses. This can cause search engines to classify documents as duplicates. So you need to redirect to the domain you are using.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^12\.34\.56\.789$
RewriteRule ^(.*)$ [L,R=301]
</IfModule>
What you see above is redirecting the IP address to the domain. Replace ^12\.34\.56\.789 with your WordPress IP address and change http://www.domainname.com/ right below it to your domain.
Since this is important from a SEO perspective, it will work if you add it to .htaccess as everyone sets it, but it will not work if the AllowOverride directive is Nono.
Allow .htaccess operation
After you enter your Lightsail, click on your instance and then go to Connect using SSH.
When you connect using SSH, you will see a screen like the one above. Here, go to /opt/bitnami/apache2/conf/vhosts/wordpress-https-vhost.conf or /opt/bitnami/apache2/conf/vhosts/wordpress-vhost.conf and change the AllowOverride item to all.
To enter the editor, add sudo nano in front of the command as shown above.
※ The file structure itself will change. If you previously modified the httpd-app.conf file, you can now set the AllowOverride section in the wordpress-https-vhost.conf or wordpress-vhost.conf file.
Go to one of the two files I mentioned above, change the AllowOverride option under options -Indexes +FollowSymLinks to all, then press Ctrl + O to save.
If you have modified and saved it, restart Apache by entering sudo /opt/bitnami/ctlscript.sh restart apache.
You may think that using a redirect plugin would be convenient, but since plugins affect the site speed, we recommend that you try setting it up without installing a plugin using the method above.
▶ How to fix apple touch icon 404 error
▶ WordPress Hack: Feeling the Importance of Security
▶ How to fix PageSpeed Insight ‘Loading critical requests’