Reputation: 21
I am in the process of moving an existing codeigniter website from a MediaTemple shared server to a Dreamhost VPS server. I have set up a mirror of the new server to view the site without switching the DNS; you can see it here
I have attempted to switch the DNS, but the problems persisted.
As you can see, it returns a 404 error. If I remove the htaccess file, the home page will come up, but none of the html pages will work. I think that this has to do with the RewriteCond and RewriteRule statements in the htaccess file.
Here is the htaccess file:
AddHandler php-stable .php
php_flag allow_url_fopen on
# php_flag extension_dir=/home/86983/data/lib/php
# php_flag extension=zip.so
Options +FollowSymLinks
RewriteEngine on
# RewriteCond $1!^(js|css|images|license\.txt|user_guide|admin|phpMyAdmin|uploads|ornaments_sitemap2_25_09\.xml|sitemap\.xml|robots\.txt|quickscript\.php|paypal_ipn\.php|test\.php|sitedown\.php)
# RewriteRule ^(.*)$ http://www.ornaments.com/sitedown\.php [L]
RewriteCond %{HTTP_HOST} ^ornaments\.com$ [NC]
RewriteRule (.*) http://www.ornaments.com/$1 [R=301,L]
RewriteCond $1 !^(admin|backupForPhpMyAdmin|blog|change_page_name\.php|css|favicon\.ico|images|index\.php|js|license\.txt|ornaments_sitemap2_25_09\.xml|paypal_ipn\.php|phpMyAdmin|uploads|quickscript\.php|robots\.txt|sitemap\.xml|sub-domains|test\.php|testblog\.php|url_checker|user_guide|tinymy\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
# RewriteCond %{HTTP_HOST} ^s86983\.gridserver\.com$ [NC]
# RewriteRule (.*) http://www.s86983\.gridserver.com/$1 [R=301,L]
#
# RewriteCond $1 !^(blog|index\.php|js|css|images|license\.txt|user_guide|admin|phpMyAdmin|uploads|ornaments_sitemap2_25_09\.xml|sitemap\.xml|robots\.txt|quickscript\.php|paypal_ipn\.php|test\.php|backupForPhpMyAdmin)
# RewriteRule ^(.*)$ /index.php/$1 [L]
Note: I did not build this site and am only slightly familiar with codeigniter and PHP in general. Any help would be greatly appreciated.
Upvotes: 1
Views: 919
Reputation: 21
We solved this one by replacing the htaccess file with the one from the openCart part of the site that worked. That file looks like this:
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) /index.php?_route_=$1 [L,QSA]
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
#php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
#php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www.shop.ornaments.com [NC]
RewriteRule ^(.*)$ http://shop.ornaments.com/$1 [R=301,L]
I am not clear on why it worked and what might still be broken that we can't yet see, but so far it looks good.
Upvotes: 1
Reputation: 64
I suggest you copy in htaccess this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
#LoadModule rewrite_module modules/mod_rewrite.c
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
Upvotes: 1