views:

420

answers:

1

ok, so i can't tell if this is a server issue or what. i've got an htaccess file like so:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/main/index/$1 [L]
RewriteRule ^ajax/(.*)$ /index.php?/main/ajax/$1 [L]
RewriteRule ^backend.php/(.*)$ /backend.php?/$1 [L]

# 301 redirects
Redirect 301 /backup.php http://www.example.com/backup/
Redirect 301 /document.php http://www.example.com/document/
Redirect 301 /contact.php http://www.example.com/contact/
Redirect 301 /links.php http://www.example.com/links/
Redirect 301 /jobs.php http://www.example.com/jobs/

the only issue i have is with my 301 redirects. instead of

example.com/backup.php going to example.com/backup/ it instead sends it to example.com/backup/?/main/index/backup.php.

this does route the page properly. meaning i get the proper html returned but the url is ugly. i should say that this IS done in code igniter and that i'm routing EVERYTHING to the main controller's method index which makes backup, document, contact, etc the first argument of the index method. this may seem odd - and also may have no relevance - but i need it to be this way. anyone have any suggestions on how to get the redirected urls clean?

A: 

It’s not a good idea to use both mod_alias and mod_rewrite. Try this mod_rewrite rule instead of your Redirect directives and put it in front of your current rules:

RewriteRule ^(backup|document|contact|links|jobs)\.php$ http://www.example.com/$1/ [L,R=301]
Gumbo
interesting...that actually routes /backup.php to /backup.php resulting in a 404 error. :( any other thoughts?
ocergynohtna
@ocergynohtna: And you really put this rule as the first rule of your rule set?
Gumbo
i had it at the bottom where i had the 301's originally, moving it toward the top resolved the issue. Thanks Gumbo!
ocergynohtna