Lighttpd And WordPress SEO Friendly Permalinks

WordPress permalinks are the permanent URLs to weblog posts, categories and such. The URL to each post should be permanent and never change – hence permalink. They are used by other people as well as search engines to link to your posts. One of important factors for SEO (see SEO Explained) is the URL. If your post’s URL contains relevant keywords, your post will naturally rank better. WordPress default permalinks will work flawlessly in all server environments. However, they contain no keywords, and thus are very bad for SEO. Fortunately, WordPress offers almost unlimited possibilities to modify your blog’s permalinks. Just log in and go to Settings – Permalinks.



You can choose from various permalink structures but none of them is optimal. Instead, choose a custom permalink structure option, fill in /%postname%/ and save the changes. WordPress will generate rewrite rules and insert them into the proper .htaccess file. That is if a blog is running on Apache webserver.

Lighttpd
What if the blog is running on Lighttpd (Lighty) webserver? Obviously, Lighttpd doesn’t support .htaccess and mod_rewrite. There are few possible ways how to achieve pretty URLs in Lighttpd – I will demonstrate two solutions.

Without Rewrite
Go to Design – Theme Editor and make sure your theme has a 404 page (404.php file). If not, just copy the 404.php file from default Kubrick theme. Open the 404 template and add this line right at the beginning of the file:

<?php header("HTTP/1.1 404 Not Found"); ?>

This makes sure pages that are not found do send 404 response headers. That is important for search engine bots.

Finally, edit a Lighttpd configuration file. Most of the time it is located in /etc/lighttpd/conf/ folder but it depends on your server’s OS and configuration. If you don’t know where to look for it, contact your web hosting provider and kindly ask – I’m sure they will help you. Once you know where your config file is located, add this line to virtual host section:

server.error-handler-404 = "/index.php"

Now your SEO friendly permalinks should work.

With Rewrite
Another solution is to manually insert rewrite rules into the Lighttpd configuration file:

url.rewrite-once = (
  "^/(wp-.+).*/?" => "$0",
  "^/(sitemap.xml)" => "$0",
  "^/(xmlrpc.php)" => "$0",
  "^/keyword/([A-Za-z_0-9\-]+)/?$" => "/index.php?keyword=$1",
  "^/.*?(\?.*)?$" => "/index.php$1"
)

If you need to exclude some folder from rewriting, just add this line:

"^/folder-excluded-from-rewriting/.*/?" => "$0",

Here are rewrite rules used on this blog (I have excluded folders images and temp from rewriting). They work just fine on WP 2.5.1:

url.rewrite-once = (
  "^/(wp-.+).*/?" => "$0",
  "^/images/.*/?" => "$0",
  "^/temp/.*/?" => "$0",
  "^/(sitemap.xml)" => "$0",
  "^/(xmlrpc.php)" => "$0",
  "^/keyword/([A-Za-z_0-9\-]+)/?$" => "/index.php?keyword=$1",
  "^/.*?(\?.*)?$" => "/index.php$1"
)

Other Possible Solutions
Lighttpd And WordPress SEO Friendly Permalinks Lighttpd And WordPress SEO Friendly Permalinks Reviewed by Freelance Web Designer on April 28, 2020 Rating: 5

No comments:

Pay Per Click Management Service

An effective PPC campaign can lead to increased website exposure, web traffic, and sales revenues. However, choosing an experienced PPC man...

Powered by Blogger.