If you use wordpress as a blog engine and installed on the server then you can access via FTP or if your files are stored on a local server then the .htaccess file will be found in the root directory or where you installed wordpress, that is also if your hosting server allows to use this facility. For how to activate mod_rewrite see the article on X-code edition 4 entitled mod_rewrite on Apache.
Please download the wordpress source at www.wordpress.org, the latest version of the website is 2.0.5. I will not explain how to install wordpress on the server, you can search for this on the internet or follow the existing help. But the author will discuss the .htaccess file for existing links and rewrite with mod_rewrite.
1. Open the .htaccess file
Open your editor and save it with the name ".htaccess".
2. Links that we will change
Here are the links that we will change with mod_rewrite, for more details please dissect the source on WordPress:
wp-feed.php?category_name=$1&feed=$2 index.php?category_name=$1 wp-feed.php?author_name=$1&feed=$2 index.php?author_name=$1
index.php?day=$1&monthnum=$2&year=$3&name=$4&page=$5 wp-feed.php?day=$1&monthnum=$2&year=$3&name=$4&feed=$5 wp-trackback.php?day=$1&monthnum=$2&year=$3&name=$4
wp-feed.php?feed=$1
wp-feed.php?feed=$1&withcomments=1
3. Understand the contents of the mod_rewrite rule
Please copy the script below to your ".htaccess" file. In this section we will learn and explore the commands in the .htaccess file.
RewriteEngine On
RewriteBase /
RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-
feed.php?category_name=$1&feed=$2 [QSA]
RewriteRule ^category/?(.*) /index.php?category_name=$1
[QSA]
RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-
feed.php?author_name=$1&feed=$2 [QSA]
RewriteRule ^author/?(.*) /index.php?author_name=$1 [QSA]
RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})?/?([0-
9]{4})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$
/index.php?day=$1&monthnum=$2&year=$3&name=$4&page=$5 [QSA]
RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})/([0-9]{4})/([_0-9az-]+)/(feed|rdf|rss|rss2|atom)/?$ /wp-
feed.php?day=$1&monthnum=$2&year=$3&name=$4&feed=$5 [QSA] RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})/([0-9]{4})/([_0-9a-
z-]+)/trackback/?$ /wp-
trackback.php?day=$1&monthnum=$2&year=$3&name=$4 [QSA]
RewriteRule ^feed/?([_0-9a-z-]+)?/?$ /wp-feed.php?feed=$1
[QSA]
RewriteRule ^comments/feed/?([_0-9a-z-]+)?/?$ /wp-
feed.php?feed=$1&withcomments=1 [QSA]
RewriteEngine On
This command is used to enable or disable the runtime on the rewrite engine. If set to OFF then the module does not execute the runtime. Then set to ON.
RewriteBase
WordPress installed directroy, if you install in /www/wp then change RewriteBase /wp. This needs to be done if you don't want your layout to be messed up because we will rewrite it into a directory form.
RewriteRule ^category/(.*)/(feed|rdf|rss|rss2|atom)/?$
/wp-feed.php?category_name=$1&feed=$2 [QSA]
You notice that this rule will change the wp-feed.php query result with various outputs such as rdf, rss, rss2, atom. So for example we call recosmic.com/category/computer/rss/ then it will be executed by the script wp-feed.php?category_name=$1&feed=rss
with the [QSA] flag - Query String Appended flag.
RewriteRule ^category/?(.*)
/index.php?category_name=$1 [QSA]
When we call the link recosmic.com/category/kamputer, the rule will be rewritten by the script index.php?category_name=komputer.
RewriteRule ^author/(.*)/(feed|rdf|rss|rss2|atom)/?$ /wp-feed.php?author_name=$1&feed=$2 [QSA]
The link that is displayed recosmic.com/author/aksan/rss/
will actually be executed by the script. wp-feed.php?author_name=aksan$feed=rss.
RewriteRule ^author/?(.*) /index.php?author_name=$1
[QSA]
The link displayed in the browser recosmic.com/author/aksan
will actually be executed by the script. index.php?author_name=aksan.
RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})?/?([09]{4})?/?([_0-9a-z-]+)?/?([0-9]+)?/?$
/index.php?day=$1&monthnum=$2&year=$3&name=$4&page=$5 [QSA]
The link displayed in the browser recosmic.com/12/02/2006/apache_pada_windows/2/
will actually be executed by script index.php?day=12&monthnum=02&year=2006&name=apache_pada_win dows&page=2.
If you look at the date and month, they are given two digits, namely {1,2} with a limit between [0-9].
RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})/([09]{4})/([_0-9a-z-]+)/(feed|rdf|rss|rss2|atom)/?$ /wpfeed.php?day=$1&monthnum=$2&year=$3&name=$4&feed=$5
[QSA]
The link displayed in the browser recosmic.com/12/02/2006/apache_pada_windows/rss/ will actually be executed by
script wp-feed.php? day=12&monthnum=02&year=2006&name=apache_pada_windows&feed =rss
If you look at the date and month, they are given two digits, namely {1,2} with a limit between [0-9].
RewriteRule ^([0-9]{1,2})/?([0-9]{1,2})/([09]{4})/([_0-9a-z-]+)/trackback/?$ /wptrackback.php?day=$1&monthnum=$2&year=$3&name=$4 [QSA]
The link displayed in the browser recosmic.com/12/02/2006/apache_pada_windows/trackback/ will be executed by the script
wp-trackback.php?day=12&monthnum=02&year=2006&name=apache_pada_windows
Links displayed in the browser
recosmic.com/feed/rss/ akan dieksekusi oleh script wp-feed.php?feed=rss
RewriteRule
^comments/feed/?([_0-9a-z-]+)?/?$ /wpfeed.php?feed=$1&withcomments=1 [QSA]
The link displayed in the browser recosmic.com/comment/feed/rss/
will be executed by the script. wp-feed.php?feed=rss&withcomments=1.
We have finished dissecting the .htaccess file on the wordpress engine, you can make changes according to your wishes, of course you have to know and learn the programming structure used by wordpress. For example, what I did was
recosmic.com/12/02/2006/apache_pada_windows/page-2.html
then the source of my script must be changed so that there is an addition of page-2 and there is an addition of .html. Please be creative with your abilities. On another occasion we will discuss mod_rewrite on joomla, phpbb forum and others.
Don't forget to upload your ".htaccess" file to the root directory or where WordPress is installed. Good luck.
Biography
Muh Hasan Tanjung. Born in Jakarta on March 8, 1981 and has completed his Bachelor's degree in Electrical Engineering - Universitas Gadjah Mada, Yogyakarta in 2004. During college, his hobby was computers, especially the internet, so he had worked on a web-making project using ASP, PHP, MySQL and Access. His first project was to create the Bulaksumur Pos website, a UGM student community media with ASP and Access, then Kick Off. Another project was to create the MLM Acintya.net website and continued with Ayudya.net and Javaart.net (handicraft sales site via the web). In addition, the author is also developing a web-based Clinic Information System.
In addition to being an employee of a private company engaged in manufacturing (Production Spv.), it does not dampen his interest in studying and developing knowledge about web programming. The author is also active in pouring his ideas into his blog in addition to developing the blog independently as well.
Copyright / License:
- All X-Code Magazine materials can be downloaded, read, modified and distributed freely for non-commercial purposes, provided that the author's attributes are not deleted or changed.
- Copyright is in the hands of the author and X-Code Magazine by following the GPL (General Public License) license.
X-Code Magazine No. 5 Writer:
- quick -sniffer^
- SpicyCash
- rose_see
- family _code^
- Bernad_satriani / bl4ck_94m81t
- NeMeSiS_ByTe
- Muh Hasan Tanjung
- Bangs
- Yule
- Gugun Gunawan
- Max-keZee
- BLiZBS Uchiha