我有一个博客,我正在使用我的htaccess文件来整理网址路径,但我想让它们更有活力。
所以目前我有网址:
http://myname.com
http://myname.com/blog
http://myname.com/blog/articles
http://myname.com/blog/articles/category
http://myname.com/blog/article/19498/title-of-my-article
但是我看到一个网上的人有一个博客,他的网址是这样的:
http://hisname.com
http://hisname.com/blog
http://hisname.com/category
http://hisname.com/title-of-his-article
这似乎阻止了blog
目录以及articles
和article
页面。我如何使用目前看起来像这样的htaccess文件来实现同样的目的:
Options -MultiViews
DirectoryIndex articles.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^articles/([\w-]+)/?$ articles.php?cat=$1 [NC,L,QSA]
RewriteRule ^articles/([\w-]+)/([0-9]+)/?$ articles.php?cat=$1¤tpage=$2 [NC,L,QSA]
RewriteRule ^article/([0-9]+)/([\w-]+)/?$ article.php?id=$1&title=$2 [NC,L,QSA]
RewriteRule ^articles articles.php
RewriteRule ^categories categories.php