09 March 2022

How To Setup Pretty Permalinks In Wordpress

Setup pretty permalink in wordpress is easy to do. Not because your site will look pretty when it is done. If you want your site look pretty, you can go with wordpress theme and then install it. They said many seo gurus told them that pretty permalink is needed to make your blog post seo friendly. Google, the master of search engine right now, will display your site on the SERP with this permalink.

For example, your blog post is about "grammarly review". So you can setup your permlink: "grammarly-review" or "grammarly-review". For a good reason I found a site not using pretty permlink, and their traffic is pretty high and stabil. This is the screenshot of the site: https://www.server-world.info/en/

Pretty Permalinks Wordpress

The example of it's permalink: https://www.server-world.info/en/note?os=Ubuntu_20.04&p=download. You can see the permlink is not much pretty. And their traffic is good. I know it is my opinion, what is yours? How much traffic your site is getting right now? This is the screenshot of their traffic.

Pretty Permalinks Wordpress

According to similar web, the tool I use, their traffic is about 280.000 per day. If the real traffic is 5%, so their actual traffic is 14.000 per day.

So why you need pretty permalink for your wordpress blog if not pretty permalink could get enough traffic to make money? My opinion, if a site that is not having pretty-permalink can get traffic from search engine there is no reason that having permalink can not get a traffic. An seo strategy must apply to a site to have a traffic. Not depend only on the pretty permalink.

After seeing this example, I still insist you and me to setup pretty permalink for wordpress-powered blog. This is simple and fast. And after all nothing wrong with it.

Setup Pretty Permalink In Wordpress

By default permalink of wordpress is: http://domain.com/?p=1. It is not easy to remember, but most people that coming from search engine to your site will not try to remember it. They will bookmark if like. Might be, another kind of person is willing to remember your permalink if love your site so much.

Pretty permlink wordpress setup guide :

1. Login to your wordpress admin panel with correct username and password.

2. Put your mouse cursor on settings menu. Few menus will show up, click on permalink menu.

Pretty Permalinks Wordpress

You will see several option for your permalink setup.

• Day and name. Your permalink will be: http://domain.com/year/month/day/sample-post/. Example, your permalink will look like this: http://domain.com/2020/07/24/slug-of-the-post/

• Month and name. Your permalink will be: http://domain.com/year/month/sample-post/. Example, your permalink will look like this: http://domain.com/2020/07/slug-of-the-post/

• Numeric. Your permalink will be: http://domain.com/archives/123/. Example, your permalink will look like this: http://domain.com/archives/post_id/. The post_id could be 1, 2, 3, 4, etc depending on the id that is stored in the database.

• Post name. Your permalink will be: http://domain.com/sample-post/. Example, your permalink will look like this: http://domain.com/2020/07/slug-of-the-post/

• Custom structure. You can setup custome permalink like: http://domain.com/year/postname. And the permalink will look like this: http://domain.com/2020/slug-of-the-post. Another custom structure is available, you can try it yourself.

Server Setup

To setup pretty permalink in wordpress, firstly you have to setup the server to make it works. In this article I will cover on how to setup the simple server that hosting provider using the most, apache and nginx server.

Apache Setup

To make your pretty permalink setup works, you must setup your server properly. For apache server user, you have two option to make it works. Firstly, you have to enable mod_rewrite.

Debian/Ubuntu Server

To install it, you have to run this command via command line if you are ubuntu/debian server user.

sudo a2enmod rewrite

Restart the server.

sudo systemctl restart apache2

Centos/Fedora Server

To enable mod_rewrite on centos/fedora server, do these:

a. sudo nano /etc/httpd/conf.modules.d/00-base.conf

b. Find the following line and Uncomment it to enable the mod_rewrite.

LoadModule rewrite_module modules/mod_rewrite.so

Then restart your server.

sudo systemctl restart httpd

Now, lets get your permalink look pretty.

Option 1: Using .htaccess

• It is quite simple. Create .htaccess file.

sudo nano .htaccess

• Add the following into .htaccess file and save the file.

# BEGIN WordPress # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <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 option will work only on apache server. If you are using nginx server, you do not need .htaccess file.

Option 2: Without .htaccess

In order to enable pretty permalink without .htaccess, do this step by step:

• Put the following code into your site configuration

# BEGIN WordPress # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <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

Debian/Ubuntu Server User

sudo nano /etc/apache2/sites-available/thesite.conf

Then, restart the server

Centos/Fedora Server User

sudo nano /etc/httpd/sites-available/thesite.conf

Then, restart the server

• The example of site configuration.

<VirtualHost *:80> # (1) ServerName example.com ServerAlias www.example.com DocumentRoot "/var/www/example.com/public" <IfModule mod_rewrite.c> # BEGIN WordPress # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <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 </IfModule> </VirtualHost>

• If your site using ssl, here is the site configuration example.

</VirtualHost> <VirtualHost *:80> ServerName www.example.com Redirect / https://example.com </VirtualHost> <VirtualHost _default_:443> ServerName secure.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc... </VirtualHost>

Nginx Setup

Nginx server does not support .htaccess file. For nginx server user, the site configuration could be like this.

server { listen 80; server_name example.com; index index.php; root /home/username/sites/example.com/public; location / { try_files $uri $uri/ /index.php$is_args$args; } }

If you are using default site configuration, you can find the default site configuration in /etc/nginx/conf.d, find the following lines :

location / { root /usr/share/nginx/html; index index index.htm; }

And make a change to that lines into this:

location / { root /usr/share/nginx/html; index index index.htm; try_files $uri $uri/ /index.php?$args; }

Save the file and reload Nginx:

sudo service nginx reload

Conclusion

It is easy to setup pretty permalink in wordpress. For shared hosting user, for example: siteground hosting, you do not need to setup the complicated server to make it works. Just install the wordpress, and the pretty permalink will work with no additional setup. If you are using unmanaged vps or dedicated server, additional setup info I cover in this article hope help.

Comments are closed