CodeIgniter Framework: 500 Internal Server Error - codeigniter

I am developing project using CodeIgniter framework and when I am running my project from Xampp it shows a 500 Internal Server Error. How to resolve Error 500 in CodeIgniter framework or Is this error of htaccess file?
SetEnv MAGIC_QUOTES 0
SetEnv PHP_VER 5
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /aip
RewriteCond %{REQUEST_URI} ^base.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^(dishme\.com\.au)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|css|fonts|woff|ttf|eot|svg|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /aip/index.php?/$1 [L]
#Block libwww-perl attacks
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Use this htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Related

htaccess Rewriterule if url contains a specific word, keep the rest of URL

Facebook recently added a tracking script/parameter: &fbclid=....
So when people click on a link from a Facebook page which refers to my website (portfolio), my website can't find the right page.
An example:
This is the url facebook creates: http://stanbroeksteeg.nl/portfolio?video=296818340&fbclid=IwAR1OuXwzLVBQDFSgeNzCVgJ7lkCNhWeHZwhOe2vs9SmZzCYFMcBDJ6N-lX8
My website quickly changes it to:
http://stanbroeksteeg.nl/portfolio?video=296818340&fbclid
This results in the page not being found. So what i want to do is the following:
If the url contains &fbclid remove this part and KEEP the rest of the URL. So if i take the example URL is needs to be like this:
http://stanbroeksteeg.nl/portfolio?video=296818340
I've come up with this these Rewrite rules:
RewriteCond %{QUERY_STRING} “fbclid=” [NC]
RewriteRule (.*) /$1? [R=301,L]
or
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=(.*)$ [NC]
RewriteRule ^/?(.*)$ /$1?%1 [R=301,L]
But both rules do not resolve the issue.
Can somebody help me with this?
This is my current .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?page=$1 [QSA]
SetOutputFilter DEFLATE
<FilesMatch ".(eot|ttf|otf|woff|woff2)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
I found a solution for my problem
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Hope it can help others in the future
#Bram's solution worked in my Wordpress. Here is the .htaccess code before and after.
Before:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
After:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)&?fbclid=[^&]+&?(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Laravel's HTTP Basic Authentication works locally, but not on remote server

I have a blog where I've created a simple admin section. I decided to use Laravel's implementation of basic authentication since I would be the only one needing access. This works fine for me locally, but when I push my code to the server it's not allowing me to authenticate.
To troubleshoot this, I first ssh into my server and try the following steps:
run php artisan key:generate
run php artisan tinker
$user = new User;
$user->email = 'name#email.com';
$user->username = 'name#email.com';
$user->password = Hash::make('1234');
$user->save();
Confirm the database entry looks right: 4|name#email.com|name#email.com|xxxxxxxxxxxxx|2014-09-25 14:07:20|2014-09-25 14:07:20
Try authentication
I have FastCGI enabled, so added the additional requirements for my .htaccess file per Laravel's documentation:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# HTTP Authentication if FastCGI is enabled
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 2 hours"
ExpiresByType application/javascript "access plus 2 hours"
ExpiresByType application/x-font-woff "access plus 2 hours"
ExpiresByType font/truetype "access plus 2 hours"
ExpiresByType font/opentype "access plus 2 hours"
ExpiresByType image/png "access plus 2 hours"
</IfModule>
</IfModule>
However, it's still not working. Any suggestions I can try to debug this?
Thanks!
Matt
I just stumbled over this myself and realized I was editing the wrong .htaccess - the one in the root folder. Edit the .htaccess in your public/-folder and you should be good to go.

Can't access file via ajax (Error 500)

I try to access a file via Ajax but all I get is an error 500.
I need access to the following file:
/templates/***/sections/popular.php
It works on localhost (MAMP) but when I uploaded my site to my server ajax stopped working.
The php error log is empty. Permission of the directories and file (see above) is 755. I use Hostgator.
This is my htaccess-file:
#ultimate htaccess-file
<Files .htaccess>
order allow,deny
deny from all
</Files>
AddDefaultCharset utf-8
AddCharset utf-8 .html .css .js .xml .json .rss .atom
#end ultimate htaccess-file
#prevent directory listing and redirect to 404-php
Options -Indexes
ErrorDocument 403 /index.php
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&page=$3 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&sortby=$3&page=$4 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+)/([0-9a-zA-Z?-]+)-([0-9]+) index.php?task=category&id=$1&sortby=$3&page=$4 [L]
RewriteRule ^cat/([0-9]+)?/([^/\.]+) index.php?task=category&id=$1&name=$2 [L]
RewriteRule ^tag/([^/\.]+)/([0-9a-zA-Z?-]+)/([0-9]+) index.php?task=tag&t=$1&sortby=$2&page=$3 [L]
RewriteRule ^tag/([^/\.]+) index.php?task=tag&t=$1 [L]
RewriteRule ^profile/([0-9]+)?/([^/\.]+) index.php?task=profile&id=$1&name=$2 [L]
RewriteRule ^profile/comments/([0-9]+)?/([^/\.]+) index.php?task=users_comments&id=$1&name=$2 [L]
RewriteRule ^page/([0-9]+) index.php?task=view_page&id=$1 [L]
#RewriteRule ^register index.php?task=register [L]
RewriteRule ^lost-password index.php?task=lost_pass [L]
RewriteRule ^links index.php?task=links [L]
RewriteRule ^news/item/([0-9]+)/([^/\.]+) index.php?task=news&id=$1 [L]
RewriteRule ^news/page([0-9]+) index.php?task=news&page=$1 [L]
RewriteRule ^members/([^/\.]+)-([^/\.]+)/page([0-9]+)? index.php?task=member_list&sort=$1&order=$2&page=$3 [L]
RewriteRule ^members index.php?task=member_list [L]
RewriteRule ^messages index.php?task=messages [L]
RewriteRule ^submit-game index.php?task=submit [L]
RewriteRule ^search/([^/\.]+) index.php?task=search&q=$1 [L]
RewriteRule ^search index.php?task=search [L]
RewriteRule ^friends index.php?task=friends [L]
RewriteRule ^submit index.php?task=submit [L]
RewriteRule ^newest-games.rss rss.php [L]
RewriteRule ^r-([0-9]+)?-([0-9]+)? go.php?id=$1&ref=$2 [L]
RewriteRule ^r-([0-9]+)? go.php?id=$1 [L]
RewriteRule ^([^/\.]+)/([0-9]+)/([^/\.]+) index.php?task=view&id=$2 [L]
RewriteRule ^news/([^/\.]+) index.php?task=news&name=$1 [L]
RewriteRule ^profile/([^/\.]+) index.php?task=profile&name=$1 [L]
RewriteRule ^news index.php?task=news [L]
RewriteRule ^page/([^/\.]+) index.php?task=view_page&name=$1 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+)?-newpost avforums/core/find_post.php?forum_name=$1&name=$2&topic_id=$3 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+)?-findpost([0-9]+)? avforums/core/find_post.php?forum_name=$1&name=$2&topic_id=$3&post_id=$4 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+)/([0-9]+) index.php?task=topic&forum_name=$1&name=$2&page=$3 [L]
RewriteRule ^forums/([^/\.]+)?/([0-9]+) index.php?task=forum&name=$1&page=$2 [L]
RewriteRule ^forums/([^/\.]+)/([^/\.]+) index.php?task=topic&forum_name=$1&name=$2 [L]
RewriteRule ^forums/([^/\.]+) index.php?task=forum&name=$1 [L]
RewriteRule ^forums index.php?task=forums [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/([0-9a-zA-Z'?-]+)/([0-9]+) index.php?task=category&name=$1&sortby=$2&page=$3 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/([^/\.]+) index.php?task=view&cat=$1&name=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+) index.php?task=category&name=$1 [L]
#ultimate htaccess-file
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot#yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots
Deny from env=block_bad_bots
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to send this header on *everything*
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
AddType application/javascript js
# Audio
AddType audio/ogg oga ogg
AddType audio/mp4 m4a
# Video
AddType video/ogg ogv
AddType video/mp4 mp4 m4v
AddType video/webm webm
# SVG
# Required for svg webfonts on iPad
# twitter.com/FontSquirrel/status/14855840545
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Webfonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType text/cache-manifest appcache manifest
AddType text/x-component htc
AddType application/x-chrome-extension crx
AddType application/x-xpinstall xpi
AddType application/octet-stream safariextz
AddType text/x-vcard vcf
AddType application/futuresplash spl
AddType application/x-shockwave-flash swf
AddType application/vnd.android.package-archive apk
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# RSS feed
ExpiresByType application/rss+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
ExpiresByType font/truetype "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
Header append Cache-Control "public"
Header unset ETag
FileETag None
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
#end of ultimate htaccess-file
Update: The folder (* * *) above 'sections' has an .htaccess-file. This is the content:
<files ~ "\.php$">
order deny,allow
allow from none
deny from all
</files>
Solution
Apache was not able to execute an htaccess-file located in the 'sections'-folder. I just had to remove two colons after the IP-address of my site (initially I inserted them because of Google Chrome (localhost)).
Try wrapping your directives in <IfModule> containers. That way, if a module isn't loaded, it won't cause a 500 server error.
For exmaple, starting from:
RewriteEngine on
all the way to:
RewriteRule ^.* - [F,L]
Wrap that entire block of directives inbetween a:
<IfModule mod_rewrite.c>
# all your rewrite stuff goes in here
</IfModule>
And the same with any Header line, like:
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to send this header on *everything*
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
Can be wrapped:
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to send this header on *everything*
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
and all of your expires stuff, starting from:
ExpiresActive on
to
ExpiresByType text/javascript "access plus 1 year"
can be wrapped in:
<IfModule mod_expires.c>
# all your expires stuff goes here
</IfModule>
Then if you stop getting the 500 server error, make sure mod_expires, mod_headers and most importantly
mod_rewrite is loaded. Though it would seem by default mod_rewrite is loaded on hostgator.

codeigniter's redirect redirects me to index.php constantly

I'm using a dull redirection :
redirect('/home/login/');
for when the user is not logged. But it keeps redirecting me to
/index.php/home/login/
While I have this in my .htaccess :
RewriteRule ^(.*)$ /index.php/$1 [L]
Possible solution 1:
make .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /#MY_DIRECTORY#
RewriteRule ^(#MY_DEFAULT_CONTROLLER#(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
*EDIT My_Application_Folder\Config.php*
$config['base_url'] = '/#MY_DIRECTORY#';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Possible solution 2:
make .htaccess
RewriteEngine on
RewriteBase /#MY_DIRECTORY#
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
*EDIT My_Application_Folder\Config.php*
$config['base_url'] = '/#MY_DIRECTORY#';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
Note: #MY_DIRECTORY# is on live server subdom directory (eg. first.example.com) - just for example and handling multiple application on one system CI
Don't forget to set for files rules in htaccess or in output custom library
AddDefaultCharset UTF-8
Header unset Pragma
FileETag None
Header unset ETag
1 YEAR
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</filesMatch>
2 HOURS
<filesMatch ".(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</filesMatch>
CACHED FOREVER /MOD_REWRITE TO RENAME EVERY CHANGE
<filesMatch ".(js|css)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
Header unset Last-Modified
</filesMatch>

mod_rewrite to direct some requests to a new directory

I have a website with a frontend and a backend that all run through index.php. To access the back end you would go to http://www.mysite.com/Admin. This will still run through index.php but then connect to the database and go to the correct directory. The backend manages donation information that is collected on the site.
I want to change the front end to WordPress but still collect donation information in the original database and view it from the backend.
Rather than rewrite all the code, I was wondering if there was a way I could use mod-rewrite and place the WordPress files in a separate directory. This way any request that included /Admin as the start would go through the original index.php and any other request would redirect to directory with WordPress.
I originally tried:
RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]
but a request for /Admin just gives me a 404 error.
Thanks in advance for any help.
This is the full .htaccess file
RewriteEngine On
Options -Indexes
# Serve 'gate' as php
<Files gate>
SetHandler application/x-httpd-php
AcceptPathInfo On
</Files>
FileETag MTime Size
AddCharset UTF-8 .xml
AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
AddType video/ogg ogv
AddType audio/ogg ogg oga
AddType video/webm webm
# redirect all domains (.net, .com, .biz, etc) to .org
RewriteCond %{HTTP_HOST} !^www\.mysite\.org$ [NC]
RewriteRule ^(.*)$ http://www.mysite.org/$1 [R=301,L]
# Route search
RewriteRule ^search$ /search/ [R,NC,L]
RewriteCond %{REQUEST_URI} !^/Admin
RewriteRule ^(.*)$ gpf/$1 [L]
# Route domain plus slash correctly
RewriteRule ^$ /gate/ [L]
# All requests: serve _gate_ as php. 1st arg is requested URL qs preserved
RewriteRule ^([0-9A-Z].*) /gate/$1 [QSA,L]
RewriteRule ^rss\.xml /gate/rss.xml [QSA,L]
# PHP directives - should comment out on production server
php_value display_errors 1
php_value display_startup_errors 1
AddOutputFilterByType DEFLATE text/html application/x-javascript text/css text/javascript text/plain
<IfModule mod_expires.c>
ExpiresActive On
# Manually change filenames for static images. CMS changes names in dyn
ExpiresByType image/gif "access plus 9 months"
ExpiresByType image/jpg "access plus 9 months"
ExpiresByType image/jpeg "access plus 9 months"
ExpiresByType image/png "access plus 9 months"
# Rare changes. manually change filename
ExpiresByType image/x-icon "access plus 9 months"
ExpiresByType image/vnd.microsoft.icon "access plus 9 months"
# PDFs should never change. CMS renames in dyn
ExpiresByType application/pdf "access plus 6 months"
ExpiresByType application/x-pdf "access plus 6 months"
# Frequent changes. ASFU dynamic rename
ExpiresByType text/css "access plus 6 months"
ExpiresByType text/javascript "access plus 6 months"
ExpiresByType application/x-javascript "access plus 6 months"
</IfModule>
Try adding an additional condition:
RewriteCond %{REQUEST_URI} !^/Admin
RewriteCond %{REQUEST_URI} !^/gate
RewriteRule ^(.*)$ /gpf/$1 [L]
And move the rules after all of the /gate/ rules.

Resources