Forum Moderators: phranque

Message Too Old, No Replies

<IfModule mod rewrite.c> & 301 redirect

         

victorP

1:58 am on Oct 25, 2006 (gmt 0)

10+ Year Member



I just installed this code but am not sure if it is the most efficient way of redirecting. Does the <IfModule mod_rewrite.c> tag make any difference?

Any comments would be greatly appreciated.

Thanks in advance.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.php? [NC]
RewriteRule ^(([^/]*/)*)index\.php?$ [mysite.net...] [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite\.net [NC]
RewriteRule ^(.*)$ [mysite...] [R=301,L]
</IfModule>

jdMorgan

12:19 am on Oct 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The IfModule container is used to prevent errors and warnings from filling up the logs files on big multi-server sites where some servers may not have a particular Apache module loaded. The code enclosed in the IfModule container will be interpreted only if the module that handles the enclosed directives is loaded. Otherwise, those directives are ignored.

Using IfModule containers can lead to 'silent' failures, so it should only be used if you want to skip the enclosed code without generating any errors or warnings when the enclosed directives require a module which is not loaded.

With an IfModule in place, the code simply won't execute, so the function it implements won't work. Without the IfModule, the server will throw an error if the code contains a directive for an unloaded module. So, it's up to you to decide whether to use IfModule or not.

Jim