Welcome to WebmasterWorld Guest from 18.232.124.77

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

<IfModule mod rewrite.c> & 301 redirect

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

Junior Member

10+ Year Member

joined:June 18, 2005
posts:49
votes: 0


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>

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

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


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