Wednesday, June 26, 2013

Top 3 Apache Rewrite Tips

Maintenance

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance.html
RewriteRule (.*) /maintenance.html [R]

Serve page without 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [L] 

Serve page with 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [R,L]

Friday, June 21, 2013

Serve Pages from Subfolder on Apache

Multiple site hosting on one hosting account in subfolders

Directory structure for domains example.com and otherexample.com

[Folder] public_html
[File  ]    .htaccess
[Folder]    example.com
[File  ]         index.php
[Folder]    otherexample.com
[File  ]         index.php

Content of .htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} example.com
RewriteCond %{REQUEST_URI} !example.com/
RewriteRule ^(.*)$ example.com/$1 [L]


RewriteCond %{HTTP_HOST} otherexample.com
RewriteCond %{REQUEST_URI} !otherexample.com/
RewriteRule ^(.*)$ otherexample.com/$1 [L]

index.php file could be a WordPress index.php that resides in web root folder.

Thursday, June 6, 2013

Basic APC Tutorial

APC is very powerful caching system for PHP. Here are some basics. First run test_apc.php and if you in 5 seconds click on delete link the key "str" will be deleted from cache. If you click on delete link after 5 second the key "str" will expire from APC caching system.

Saturday, June 1, 2013

Serve Multiple Sites from Singe IP Address on Apache

If you want to run multiple sites on one Apache web server say several PHP frameworks - this is how you need to set up the XAMPP server. For WAMP server you need to keep in mind that there are two httpd.conf files and two httpd-vhosts.conf files so you need to modify the right ones.
Don't forget to include DirectoryIndex index.php line in your virtual hosts 'cause some frameworks will not work without it.

Most Frequent WordPrees actions and shortcode

To follow this tutorial you need to know WordPress basics about plugins and shortcode.
Just replace the Hello Dolly plugin with this code: