I don’t know much about .htaccess files and rewrite, and after googling a little I am not sure if I have the time too
My current .htaccess file looks as follows and was set up by the developers of my site
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>
YEARS AGO, I wrote a tutorial about mod_rewrite in a vain attempt to eliminate Carpal Tunnel Syndrome for typing the same answers over and over. As the Team Leader, I incorporated most of my signature’s tutorial in this board’s sticky threads. If you don’t take the time to read the stickys or look through current threads, there is little hope that you can learn anything about mod_rewrite.
As for your code:
[COLOR="#FF0000"]<IfModule mod_rewrite.c>[/COLOR]
RewriteEngine On
# Removes index.php
[COLOR="#FF0000"]RewriteCond $1 !\\.(gif|jpe?g|png)$ [NC][/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?[COLOR="#FF0000"]/[/COLOR]$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
[COLOR="#FF0000"]</IfModule>[/COLOR]
The <IfModule> has drawn my ire for years so that it’s become my …
[standard rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/standard rant #4]
That’s nothing personal - except that I must recommend that you not use code you don’t understand.
Using the No Case flag against any variable but the {HTTP_HOST} WILL cause problems because URIs are case sensitive. Again, please learn what the flags do before using them.
Your first conditional is essentially, irrelevant, as the file and directory tests which follow will cause the match to fail when a file/directory exists.
I don’t know what Apache (or PHP) will make of a directory separator immediately following a query string marker (in the redirection).
Without testing using an R=301 flag, you won’t see your redirections (without a lot of help from PHP).
I would think that following my signature’s tutorial through the development of mod_rewrite code for “a typical problem” will be of great help to you. Following that, I’ve also provided a section of sample code which handles most of the problems which members have brought here in the past and found useful.
Finally, while I apologize for seeming to take out my frustrations on you, I would hope that you take it as constructive criticism and try to learn from it. Sharing the knowledge was my only reason for being in this forum for so long and dropping in on occasion now.
As a small addition (David did a very good job there!) I would use 302 redirects for testing and only use 301 in production. The reason is that browsers are allowed to cache 301 redirects, so once they’ve been redirected they can redirect perform themselves on the same input URL without even hitting your server at all and if you don’t realize this you can be tweaking your rules for hours on end only to find they did work but you were just getting cached responses from your browser instead of from your server…
Browsers are not allowed to cache 302 redirects, so you don’t get that behavior there
Rémon, I believe you’re correct … although I’ve not tested whether 302 shows up in the location box (as I’d think it would). I guess one just gets lazy when using a test server.