WordPress Redirection

Whenever I go to www.domain.com it is redirected to Non-www and the browser shows domain.com . There is no redirect rules set and I checked my .htacces file. I knew it is something to do with my wordpress . My WordPress is installed in the root directory and not in its own subdirectory called /blog or /wordpress .

Here is how I fixed it . Consider my domain name is domain.com and username : doma
# mysql –user=doma –password=mypass

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 399164
Server version: 5.0.88 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database |
+——————–+
| information_schema |
| doma |
+——————–+
2 rows in set (0.00 sec)

mysql> use doma;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+———————–+
| Tables_in_doma |
+———————–+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_terms |
| wp_usermeta |
| wp_users |
+———————–+
11 rows in set (0.00 sec)

mysql> desc wp_options;
+————–+———————+——+—–+———+—————-+
| Field | Type | Null | Key | Default | Extra |
+————–+———————+——+—–+———+—————-+
| option_id | bigint(20) unsigned | NO | PRI | NULL | auto_increment |
| blog_id | int(11) | NO | | 0 | |
| option_name | varchar(64) | NO | UNI | | |
| option_value | longtext | NO | | NULL | |
| autoload | varchar(20) | NO | | yes | |
+————–+———————+——+—–+———+—————-+
5 rows in set (0.00 sec)

mysql> select * from wp_options where option_name=’siteurl’;
+———–+———+————-+———————+———-+
| option_id | blog_id | option_name | option_value | autoload |
+———–+———+————-+———————+———-+
| 2 | 0 | siteurl |
http://domain.com | yes |
+———–+———+————-+———————+———-+
1 row in set (0.00 sec)

There you can see the siteurl is given without www . Below I’m going to change it to www .

mysql> update wp_options set option_value=’http://www.domain.com’ where option_name=’siteurl’;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0

mysql> select * from wp_options where option_name=’home’;
+———–+———+————-+———————+———-+
| option_id | blog_id | option_name | option_value | autoload |
+———–+———+————-+———————+———-+
| 38 | 0 | home |
http://domain.com | yes |
+———–+———+————-+———————+———-+
1 row in set (0.00 sec)

mysql> update wp_options set option_value=’http://www.domain.com’ where option_name=’home’;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

Done . Isn’t that cool ? :)

Submitted by,

Manjula Kesavan,
System Administrator,
LogicSupport.com

Tags: , , , , ,

Leave a Reply

You must be logged in to post a comment.