Apache HTTP Server or IBM HTTP Server mod_rewrite Example

Having a hard time with the mod_rewrite?
This example is showing you how to simply redirect from bad.html to good.html.

1. Modify your httpd.conf as follows:

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteRule   ^/bad\.html$    good.html   [R]

2. If you use a VirtualHost for port 443, also include the lines above within the VirtualHost tags.

<VirtualHost *:443>
...
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteRule   ^/bad\.html$    good.html   [R]
</VirtualHost>

3. Restart your web server.

3. Test the redirection by accessing http://yourhost.com/bad.html

More examples and extensive documentation.

Comments

  1. The VirtualHost thing is what got me! Thanks for your post, it was helpful!!

    ReplyDelete

Post a Comment

Popular posts from this blog

Ant Example: Check if a directory is empty or if specific file exists.

Django (1.2.3) CRUD Using Generic Views

Creating a Custom WebSphere Portal 8 Theme with the Eclipse IDE