Monday, September 12, 2016

How to Setup Canonical Domain Names with Apache

Canonicalization is the method used to setup your web server so that it picks the best URL when there are several choices. This usually refers to the home page of a website. For example, most people would consider the URLs all the same URL. However, as far as your web server is concerned all of these are unique and different URLs. Using canonical URLs you can merge all of these so that your web server treats them all the same in a web browser. This has a positive impact on search engine optimization. Not using canonical URLs has a negative impact on your SEO, as Google notices that several URLs are returning the same content and penalizes you.

What is a Canonical Domain Name?

Canonical domain name is the full form of CNAME. You might have encountered this term while setting up your domain name. CNAME is an entry, which is a part of your domain's DNS records. A computer hosting a website has an IP address, which is used to access the content over the web. DNS helps us avoid distributing numeric IP addresses to people and handles the conversion from domain names to IP addresses. This is pretty straightforward when you have one website being served by an IP address. However, you might want to serve various websites with the same IP address and the same domain name. This can be done using subdomains such as forums.sevenacross. The subdomains are handled by the domain's CNAME records.
Many hosting services atomically add a CNAME entry for the subdomain www so that people accessing your website as or are both directed to your site. This might seem like a good idea and quite helpful, but it's not really a good thing. Google sees two copies of everything and you lose points on the SEO front. Let's see how to fix this issue.

Fixing the Problem

This problem has a rather simple fix. If you are familiar with URL rewriting in Apache then you should be able to skip straight to the code below. For the rest I'll give a brief explanation of how to implement the fix. If you are on a dedicated server and have access to your server's Apache configuration file, which is usually located at/etc/http/conf/httpd.conf, then you can add the code below to the file. If you are on a shared environment, you might not have access to edit the httpd.conf file. In such a case, you can create a file called .htaccess with the content below and place it in the root folder of your website.
1Options +FollowSymlinks 
2RewriteEngine on 
3RewriteCond %{HTTP_HOST} ^sevenacross\.com 
4RewriteRule ^(.*)$$1 [R=301,L]  
view plain | print | ?
Remember to edit the code shown above and replace the domain with your own domain. Save the file. You will need to restart your web server if you chose the method where you edited the httpd.conffile. The code above takes all requests to your website that come with the access beginning with and redirects them to This works for all sub-URLs as well. So if a user types the address she will be automatically directed to All this while keeping Google happy.

Fine Tuning

There might be a scenario where you want to use your website without the www at the beginning of the domain. You would need to modify the code above slightly to make that happen:
1Options +FollowSymlinks 
2RewriteEngine on 
3RewriteCond %{HTTP_HOST} ^sevenacross\.com 
4RewriteRule ^(.*)$$1 [R=301,L]  
view plain | print | ?
You can apply a similar method to redirect your users to a home page. Say you want all users access the address to be redirected to You can redirect users to this address automatically by adding the following configuration to your Apache configuration file:
1Options +FollowSymlinks 
2RewriteEngine on 
3RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
4RewriteRule ^(.*)$$1 [R=301,L]  
view plain | print | ?
You can replace index.php with anything else. You might want to change the extension to .html or .asp, or to home.php. Make sure you run a check of the settings after you apply them. A pretty simple fix for a potentially big SEO headache.

Tuesday, September 6, 2016

AIX to Linux Quick sheet

I know its been done more than a million times now, and you can probably Google the information till the end of time but sometimes you need to recall the command for something you wrote 5 years ago.  So I found this nice table of AIX to Linux commands and system files, so as its useful I would like to keep it to hand and this seemed like the best place for it.  Some of these I use everyday so are rather obvious, but as I'm switching between AIX/Linux is easy to get mixed up.  First is AIX to SUSE, but I'll add in the Redhat ones soon, most are the same so should work on both (LVM specific for example). Feel free to ping me any corrections or examples of your own:
Common System Files
Password file/etc/passwd/etc/passwd
Encrypted password file/etc/security/passwd/etc/shadow
Error logs
Group files
Secure login
Hosts file/etc/hosts/etc/hosts
Device filesODM at /etc/objrepos/dev
File systems/etc/filesystems/etc/fstab
ODM database at
/etc/sysconfig/network (SUSE)
/etc/sysconfig/network (Redhat)
/etc/sysconfig/network-scripts/if* (Redhat)
NFS exports
System environment
Common User-related
New user profile/etc/.profile/etc/skel/*.*

Specific Commands
Listing physical volumes (PV)lspvpvdisplay
List partitions in a disklspv -l <disk>fdisk -l <disk>
List volume groups (VG)lsvgvgdisplay
Create volume groupmkvgvgcreate
Remove volume grouprmvgvgremove
Add a PV to VGextendvgvgextend
Remove a VG definitionexportvgvgexport
Remove a PV from VGreducevgvgreduce
Import VGimportvgvgimport
Activate VGvaryonvgvgchange
List logical volume (LV)lslvlvdisplay
Create LVmklvlvcreate
Grow filesystems with LVchfsresize_reiserfs and resize2fs
Shrink filesystemchfsresize_reiserfs and resize2fs
Paging/Swaplsps -aprocinfo
cat /proc/swaps
OS leveloslevel
uname -a
cat /etc/SuSE-release
cat /etc/redhat-release
Run levelwho -rrunlevel
Performancevmstat, ps, sar, topas, and nmonvmstat, ps, sar, top,  and nmon (if installed)
List installed filesetslslpp -l rpm -qa
Which fileset a file is inwhich_fileset <name>rpm -qf <path/name>
Verify installed filesetslppchk -vrpm -V <package>
List files in a fileset/packagelslpp -f <fileset>rpm -ql <package>
List running kernel modulesgenkexlsmod
Insert moduleN/A (dynamic)insmod and modprobe
Unload modulesN/A (dynamic)rmmod and modprobe
List memory installedbootinfo -rfree, procinfo, and cat /proc/meminfo
Create usersmksueruseradd
Change user details chuserusermod and chage
Delete usersrmuseruserdel
Create groupsmkgrpgroupadd
Change group detailschgrpgroupmod
Delete grouprmgrpgroupdel
Install softwareinstallp, smitty install, rpm, and geninstallrpm -iv, yast -i, yast2 and yum install
Update softwaresmitty update_all, installp, and rpmrpm -Uv, yast2 and yum
Remove softwaresmit install, and rpmrpm -e, yast2 and yum
IP configurationsmitty tcpipyast2 network (SUSE) /etc/network/sysconfig/network-scripts (Redhat)
IP aliasifconfig en# alias <IP>ifconfig eth#:1<IP>
Network interfacesnetstat -inifconfig 
Network routesnetstat -rnnetstat -rn, route
staticroutessmitty route/etc/sysconfig/routes (SUSE) /etc/network/sysconfig/network-scripts (Redhat)
Network optionsno -asysctl -a
Error logserrpt and alogsyslog, evlog, tail /var/log/messages and dmesg
Start daemonsstartsrc -s (SRC Controlled)rc.svc_name start, chkconfig,
service <name> start
Stop daemonsstopsrc -s rc.svc_name stop, chkconfig,
service <name> stop
Refresh daemonsrefresh -prc.svc_name restart,
service <name> restart
Shutdown haltshutdown -hshutdown -h
Fast rebootshutdown -Frshutdown -r now
System dumpsysdumpdev -lN/A
Kernel tuningvmo (virtual memory)
schedo (scheduler)
no (network)
Change kernelChange link in /usr/lib/boot/unix_*Change in /etc/yaboot.conf
Boot imagebosbootlilo (SUSE)
Change bootlistbootlistN/A
System boot messagesalogdmesg
Hope these prove useful to you as much as they do to me.