iBelieve
sitemap | you are here: home » blog » media tips

Tour WMC-AP

WMC-AP Blog

What is a Podcast?

Welcome to the blog! You have found the place where we post our articles, stories, press releases, and testimonies from around the Asia-Pacific region. Please explore these postings and we encourge you to post your comments. We look forward to hearing from you.

With Or Without "WWW"?

comments
RSS feed

Have you encountered losing the values of your session variables using PHP language when “www.” is present on the domain name and if you remove the “www.” you can restore its value again or vise versa? This happens when a session variable was set without “www.” on the domain name, it is impossible for PHP pages to access the session variable if “www.” is present on its domain name or vise versa. So the idea is, we must declare our domain name to be accessed permanently with or without “www.” The technique behind this is called “page redirection”.

Page redirection can be done in several ways. The most common technique is by using an .htaccess file. You must have an FTP access to your account in order for you to do this. You can apply this technique if you’re creating a website by hand or if you’re using a WordPress blog application lower than version 5. Simply log in to your FTP account and create or edit the .htaccess from the root directory. Open the .htaccess with your favorite code editor and insert the following lines below:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

This code will keep the domain name WITH “www.” on it and if you encountered conflicts with your sub domains redirection, you may use the code lines below instead:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

The “!” and “www.” on the second line were removed thus leaving the “^” alone before the domain name. But the first option will work for sure - it’s very seldom to have conflicts with your sub domains.

If you want your site to be accessed permanently WITHOUT “www.” on the domain name then use the code lines below:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

If you are working with a secure site and you want to keep your specific URLs secured, use the code lines below:

RewriteCond %{SERVER_PORT} !^443
RewriteCond %{REQUEST_FILENAME} contact [OR]
RewriteCond %{REQUEST_FILENAME} admin
RewriteRule ^(.*)$ https://www.domain.org/$1 [R=302,L]

For WordPress version 5 and above, redirection can be done without using the .htaccess file. Simply log in to your WordPress Admin page and click Settings. You may add or remove “www.” on the URL fields under General Settings page.

WordPress address (URL) - Admin Page URL
Blog address (URL) - Main Blog’s Site URL

For Drupal users, once you successfully installed the application, a .htaccess is already included on the root directory or what ever directory you used during the installation. Again you may open the .htaccess file and simply follow the instruction found inside it. You may insert also the other .htaccess codes mentioned above that are not included in the .htacess file.

Page redirection using the PHP code alone will be posted soon!

this post was filed under Media Tips on May 9, 2008

Comments

  1. ASTIG! Meron palang ganitong mga Media Tips sa WMC. Good Job..Thank you for the post.
    posted by Emerald on 05/12/08, 23:20

Add Your Comments




Passcode
Would you like to receive email notices when comments are added for this episode?
Yes    No
rss feed badge - get our rss feed now del.icio.us bookmark badge - add this page to del.icio.us digg.com badge - add this page to digg.com
valid xhtml badge - validate nowvalid css badge - validate nowvalid wai-aa badgevalid xml rss feed badge - validate now