Modifying the Permalink

Modifying the Permalink

Authors in WordPress have a homepage url like http://domain.com/author/authorname where all their posts are shown. And many of us who think it doesn’t look attractive want to change that url format. The middle part of that url, which says author, is called an author_base and it is possible to change this using some rewrite rules and filters. Let’s get our hand dirty 🙂

To change the author base in permalink, you need to use the global $wp_rewrite class, like this

add_action("init","change_author_base_in_permalink");
function change_author_base_in_permalink() {
    global $wp_rewrite;
    $wp_rewrite->author_base = "users";
    $wp_rewrite->flush_rules();
}

Now, as soon as you visit http://domain.com/author/authorname you will see that it’s a 404. Good, eh? At the same time, this link http://domain.com/users/authorname will display all the posts for this particular user.

If you want to revert this change and go back to the old url structure, then all you have to do is comment that action, and then flush the permalink for once.

Other fixes

There is one small problem. Though the new permalink has been effective, but get_author_posts_url() still returns an url with the old format. So we need to fix that part too. Luckily, there is a filter 🙂

add_filter("author_link","fix_author_link");
function fix_author_link($link){
    if($link){
    return str_replace("author","users",$link);
    }
}

That’s mainly it. I hope you find this article useful.

How to disable IPv6 for Exim4 that comes with Vesta Panel

How to disable IPv6 for Exim4 that comes with Vesta Panel

I had a server which has both IPv4 and IPv6 and they were working perfectly fine. I had installed Vesta CP which is an amazing control panel application and it was working just great. But there was only one problem with Exim4. It was not sending emails properly to Gmail. Mails sent to gmail were bounced. I checked the log and the message was

message does not meet IPv6 sending guidelines regarding PTR records

Ok, that is pretty straight forward. The server’s IPv6 didn’t have a reverse DNS or PTR. To fix this problem I had to set it up. But then I was thinking how to tell Exim not touse IPv6 but IPv4. The problem begins

Exim in this server came with Vesta Panel, and in most forums people suggested to add a new entry as disable_ipv6=true in the /etc/exim4/update-exim4.conf.con file. I’ve added that and restarted exmi4, but there were no changes. Netstat shows that exim is still listening on port 25 against the IPv6 address.

netstat -tulpn | grep :25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 7013/exim4
tcp 0 0 0.0.0.0:2525 0.0.0.0:* LISTEN 7013/exim4
tcp6 0 0 :::25 :::* LISTEN 7013/exim4
tcp6 0 0 :::2525 :::* LISTEN 7013/exim4

Some people in different forum suggested that dc_local_interfaces should be set to 127.0.0.1 but it still didn’t make any change in exim.

Finally, finally, I noticed that there is a configuration template file /etc/exim4/exim4.conf.template. Curiously, I’ve added disable_ipv6=true directive over there, restarted exim and voila! It started working 🙂

netstat -tulpn | grep :25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 8110/exim4
tcp 0 0 0.0.0.0:2525 0.0.0.0:* LISTEN 8110/exim4

I hope you will find this article useful, and save some time when you run into similar problem with exim and vesta panel.

Upgrading PHP to PHP7.0 in a CentOS server with Vesta CP

Upgrading PHP to PHP7.0 in a CentOS server with Vesta CP

Latest VestaCP comes with PHP5.6 by default. In this article, we will see how to upgrade PHP to it’s latest version, i.e PHP7.0

First, we need to add the correct REMI repository and enable remi update, remi release and remi-php70 repository. Here’s how

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
yum --enablerepo=remi update remi-release
yum --enablerepo=remi-php70

Now stop apache2 and remove the existing php package that comes with VestaCP

service httpd stop
yum -y remove php

Now install PHP 7.0

yum install php70-php
yum install php70-php-pear php70-php-bcmath php70-php-pecl-jsond-devel php70-php-mysqlnd php70-php-gd php70-php-common php70-php-fpm php70-php-intl php70-php-cli php70-php php70-php-xml php70-php-opcache php70-php-pecl-apcu php70-php-pecl-jsond php70-php-pdo php70-php-gmp php70-php-process php70-php-pecl-imagick php70-php-devel php70-php-mbstring

After this step, all you need to do is stop the old php-fpm service and start the new one

service php-fpm stop
service php70-php-fpm start

At some point, you may also want to create a global alias ‘php’ to run php70 cli, like this

ln -s /usr/bin/php70 /usr/bin/php

And you’re done 🙂

Storyteller Astro Theme By Hasin Hayder