How to use mod rewrite forward to a new domain?

For examples, when we visit www.google.com, we want it redirect to http://kingphp.com, we can use the following code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

The code posted above should be used on the old server.

How to redirect folders (and all the link)

For example, if we want to redirct http://kingphp.com/php/ to http://kingphp.com/wordpress/

We could use mod_rewrite. Put this in your .htaccess file

Options +FollowSymLinks
RewriteEngine On
RewriteRule /php/(\w+).html /wordpress/$1.html [R=301,L]

Using .htaccess pointing domain to specific directory

If a server hosting 2 domains, we can use this .htaccess (on the root) to point the 2 different domains to 2 Directories on the same server:

RewriteEngine On
RewriteBase /

# pointing for the domain domain1.com to folder1
ReWriteCond %{HTTP_HOST} domain1.com
ReWriteCond %{REQUEST_URI} !folder1/
ReWriteRule ^(.*)$ folder1/$1 [L]

# pointing for the domain domain2.com to folder2
ReWriteCond %{HTTP_HOST} domain2.com
ReWriteCond %{REQUEST_URI} !folder2/
ReWriteRule ^(.*)$ folder2/$1 [L]

WordPress Permalinks Does Not Work in xampp Setup

xampp provides a convenient way to quickly and easily install and setup a web server that works without much configuration. However, permalinks feature won’t work with the default installation of xampp, even though you can properly customize the permalinks structure to create the .htaccess file. Read the rest of this entry »

.htaccess redirect ALL traffic to another domain

.htaccess code:
redirect 302 / http://www.mynewdomain.com

you can also redirect access via PHP, using the header() function:

// Permanent redirect:
header('HTTP/1.1 301 Moved Permanently', true);
header('Location: http://www.location.com/');
// Temporary redirect (note that sending the 'Location' header automatically sends a 302 redirect unless it is explicitly overwritten, as it is above):
header('Location: http://www.location.com/');

No Sidebars Defined

This should work. In sidebar.php, add this just after the first < ul > :

Add this just before the last < /ul > :

Now create a new, blank page in your editor and save it as functions.php . Place this on the new functions.php page:

if ( function_exists('register_sidebar') )
register_sidebar();
?>

Upload functions.php and sidebar.php to the theme folder. Your sidebar should now be widgetized.

How to detect the numbers of used nodes in php web host?

It is very simple, only one sentence:

print system(”find . -printf \”%i\n\” | sort -u | wc -l”);

list all posts

<h3>Posts</h3>
<ul>

                <?php while(have_posts()) : the_post(); ?>

<?php foreach((get_the_category()) as $category)
                          { $my_query = new WP_Query(’category_name=’ . $category->category_nicename . ‘&orderby=title&order=asc&showposts=100′);} ?>

                       <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

       <li><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></li>

                      <?php endwhile; ?>

<?php break; endwhile; ?>

</ul>

Code to display visitors IP address on website

get_ip_list below is a function that you must call in order to get something.

function get_ip_list() {
$tmp = array();
if (isset($_SERVER[’HTTP_X_FORWARDED_FOR’]) && strpos($_SERVER[’HTTP_X_FORWARDED_FOR’],’,')) {
$tmp += explode(’,',$_SERVER[’HTTP_X_FORWARDED_FOR’]);
} elseif (isset($_SERVER[’HTTP_X_FORWARDED_FOR’])) {
$tmp[] = $_SERVER[’HTTP_X_FORWARDED_FOR’];
}
$tmp[] = $_SERVER[’REMOTE_ADDR’];
return $tmp;
}
echo echo implode(”,”,get_ip_list());

Redirect by PC or mobile access

php code as follows:

$iswap = isset($_SERVER[’HTTP_ACCEPT’])? $_SERVER[’HTTP_ACCEPT’]:”;
if(strpos($iswap,”wap”)>0)
{
@header(”Location: /wap/”);
}