Apache Rewrite Rules

I recently worked on Migrating an Application from one oracle database to another whch included transferring over to the new htmldb apex.

I wanted to append a redirect rule onto a web link to add HTMLDB path to send users to the correct application.

Amending Apache Conf:

cd /u01/app/oracle/product/10.1/htmldb/Apache/Apache/conf/includes
more myappconfig

[LIVE]:/u01/app/oracle/product/10.1/htmldb/Apache/Apache/conf/includes : more myappconfig

<VirtualHost *>
        ServerName myapp.gen.mycompany.net
        ServerAlias myapp.live.mycompany.net
        ServerAlias myapp.live.dc1.mycompany.net
        ServerAlias myapp.live.dc2.mycompany.net
        ServerAdmin
webmaster@mycompany.co.uk
        DocumentRoot "/u01/app/oracle/product/10.1/htmldb/Apache/Apache/htdocs"

        RewriteEngine    on
        RewriteLogLevel  0

        RewriteRule ^/pls/htmldb/f   /pls/htmldb2/f?p=152:1 [R=301]
        RewriteRule ^/$ /pls/htmldb2/f?p=152:1 [R=301]
</VirtualHost>

A rewrite rule of

RewriteRule ^/$ /pls/htmldb2/f?p=152:1 [R=301]

Will append the ‘/pls/htmldb2/f?p=152:1’  anyone who goes to any of the server alias

A rewrite rule of

RewriteRule ^/pls/htmldb/f   /pls/htmldb2/f?p=152:1 [R=301]

Will change any addresses which come in with ‘^/pls/htmldb/f’ to change to ‘/pls/htmldb2/f?p=152:1’

To Add logging to the Rewrite config add the following:

       #RewriteLog  /u01/app/oracle/product/10.1/htmldb/Apache/Apache/logs/myapp.rewrite.log
       #ErrorLog    /u01/app/oracle/product/10.1/htmldb/Apache/Apache/logs/myapp.error.log
       #CustomLog   /u01/app/oracle/product/10.1/htmldb/Apache/Apache/logs/myapp.access.log combined

–to see database connectivity for apache and htmldb

/u01/app/oracle/product/10.1/htmldb/Apache/modplsql/conf : more marvel.conf

Advertisements

One Response to Apache Rewrite Rules

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: