Created
August 20, 2012 15:35
-
-
Save cam-gists/3405199 to your computer and use it in GitHub Desktop.
APACHE: Codeigniter - SEO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Please read description below : the following .htaccess file isn't enough ### | |
# 1. Activate URL rewriting | |
RewriteEngine On | |
# 2. If the base folder is different from / | |
#RewriteBase /xyz | |
# 3.a. Removes the "www" ... | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] | |
# 3.b. ... or add it | |
#RewriteCond %{HTTP_HOST} ^(.*)$ [NC] | |
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L] | |
# 4. Redirect "index.php" requests | |
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] | |
RewriteCond %{THE_REQUEST} !/system/.* | |
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L] | |
# 5. Redirect requests containing "index" if it isn't a file/folder | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{THE_REQUEST} ^GET.*index [NC] | |
RewriteCond %{THE_REQUEST} !/system/.* | |
RewriteRule (.*?)index/*(.*) /$1$2 [R=301,L] | |
# 6. Remove trailing slash if it isn't a folder | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.+)/$ /$1 [R=301,L] | |
# 7. URL rewrite for admin/connect controllers | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} ^(admin|connect)(.*) [NC] | |
RewriteRule ^(.*)$ /index.php/$1 [L] | |
# 8. URL rewrite for pages which are not admin/connect controllers | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)/?$ /index.php/site/$1 [L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment