Hi Prit,
1. I just ended a new change to improve clean urls using .htaccess
- script now works with original urls as well as with new ones. NO CONFLICTS !!
- new urls don't include "index.php and end with / to look as directories
- new urls use less and shorter keywords
Examples:
http://mydomain.com/index.php/mainPage
http://mydomain.com/main/
http://mydomain.com/index.php/viewCategory/somecat
http://mydomain.com/cat/somecat/
http://mydomain.com/index.php/viewEntry/00020/somecat
http://mydomain.com/posts/00020/somecat/
http://mydomain.com/index.php/viewEntry/00022/your-post-title
http://mydomain.com/posts/00022/your-post-title
http://mydomain.com/index.php/mainPage/allCategories/page/2
http://mydomain.com/all/2/
http://mydomain.com/index.php/viewCategory/general/page/2
http://mydomain.com/cat/general/2/
2. My .htaccess as follows:
Options +FollowSymlinks
RewriteEngine On
# single option
RewriteRule ^main/$ http://mydomain.com/index.php/mainPage [NC]
RewriteRule ^archive/$ http://mydomain.com/index.php/viewArchive [NC]
RewriteRule ^comments/$ http://mydomain.com/index.php/listAllComments [NC]
RewriteRule ^login/$ http://mydomain.com/index.php/loginPage [NC]
RewriteRule ^rss/$ http://mydomain.com/index.php/RSS [NC]
# view posts
RewriteRule ^posts/(.*)/(.*)/$ http://mydomain.com/index.php/viewEntry/$1/$2 [NC]
# category page
RewriteRule ^cat/(.*)/(.*)/$ http://mydomain.com/index.php/viewCategory/$1/page/$2 [NC] [L]
# view category
RewriteRule ^cat/(.*)/$ http://mydomain.com/index.php/viewCategory/$1 [NC]
# view allcategories / page
RewriteRule ^all/(.*)/$ http://mydomain.com/index.php/mainPage/allCategories/page/$1 [NC]
3. To use the new url format in the script, requires to adapt navigation links in the following functions (see examples above as a guide):
- listPosts()
- viewEntry()
- sidebarCategories()
- sidebarPopular()
- sidebarListEntries()
Example in listPosts():
//echo "<div class=\"post-title\"><h3><a class=\"postTitle\" href=".$_SERVER["SCRIPT_NAME"]."/viewEntry/".$fileName."/".$titleModified.">".$title."</a></h3>";
to
echo "<div class=\"post-title\"><h3><a class=\"postTitle\" href=".$BlogPath."/posts/".$fileName."/".$titleModified."/>".$title."</a></h3>";
4. Conclusions:
- new urls are fully compatible with Pritlog's original ones (can use both types)
- new urls look "cleaner" and shorter, more in line with what other sites are using
- some people say that urls that look as directories (ending in /) get better ranking
Sitemaps
- will do some more testing to see if new urls solve xml error I was getting when generating sitemaps (see sitemaps thread)
- I guess I'll probably also need to modify category separators from dot to underscore