Welcome Guest, Not a member yet? Register   Sign In
Super .htaccess file
#1

[eluser]Xeoncross[/eluser]
Well, I just wasn't happy with the default .htaccess file that is provided in the Doc's. So here is a more complex version that will keep people from accessing things like:
http://site.com/system/application/views...essage.php
Which can be accessed with the unsafe default .htaccess file.

Code:
# Deny OR Allow Folder Indexes.
# Since we disable access to PHP files you
# can leave this on without worries.
# OR better yet, create a .htaccess file in
# the dir you want to allow browsing and
# set it to +Indexes
Options -Indexes

Options +FollowSymLinks

# Set the default file for indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    # mod_rewrite rules
    RewriteEngine on

    # The RewriteBase of the system (if you are using this sytem in a sub-folder).
    # RewriteBase /CodeIgniter_1.6.3/
    
    # This will make the site only accessible without the "www."
    # (which will keep the subdomain-sensive config file happy)
    # If you want the site to be accessed WITH the "www."
    # comment-out the following two lines.
    # RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
    # RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]
    
    # If a controler can't be found - then issue a 404 error from PHP
    # Error messages (via the "error" plugin)
    # ErrorDocument 403 /index.php/403/
    # ErrorDocument 404 /index.php/404/
    # ErrorDocument 500 /index.php/500/
    
    # Deny any people (or bots) from the following sites: (to stop spam comments)
    # RewriteCond %{HTTP_REFERER} nienschanz\.ru [NC,OR]
    # RewriteCond %{HTTP_REFERER} porn\.com
    # RewriteRule .* - [F]
    # Note: if you are having trouble from a certain URL just
    # add it above to forbide all visitors from that site.

    # You can also uncomment this if you know the IP:
    # Deny from 192.168.1.1
    
    # If the file is NOT the index.php file
    RewriteCond %{REQUEST_FILENAME} !index.php
    # Hide all PHP files so none can be accessed by HTTP
    RewriteRule (.*)\.php$ index.php/$1
    
    # If the file/dir is NOT real go to index
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    
</IfModule>

# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>

With this file even valid links to .php files are blocked and you don't have to make any more annoying index.html files that say "Not Allowed". All CSS, IMG, JS, PDF, etc files are allowed AND you can enable Directory browsing (SVN) without worrying about people running your PHP files. Plus with this file you can block IP's or Referrer requests if you deal with dump bots that always come from the same place.


If you are looking for a way to turn you site into an international sensation - then you might like something like this.

Code:
RewriteRule ^(.*)-fr$ http://www.google.com/translate_c?hl=fr&sl=en&u=http://site.com/$1 [R,NC]
RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://site.com/$1 [R,NC]
RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://site.com/$1 [R,NC]
RewriteRule ^(.*)-it$ http://www.google.com/translate_c?hl=it&sl=en&u=http://site.com/$1 [R,NC]

All you would need to do is add a a couple links on your pages with the variables "-fr" appended to the end of what ever URL is in the link and your set.

Code:
//View file
View Page in &lt;a href="&lt;?php print $this->uri_string(); ?&gt;-de">German</a>


Messages In This Thread
Super .htaccess file - by El Forum - 07-16-2008, 10:10 PM
Super .htaccess file - by El Forum - 07-17-2008, 01:48 PM
Super .htaccess file - by El Forum - 07-17-2008, 08:00 PM
Super .htaccess file - by El Forum - 07-18-2008, 08:26 AM
Super .htaccess file - by El Forum - 07-18-2008, 09:31 AM
Super .htaccess file - by El Forum - 07-18-2008, 01:02 PM
Super .htaccess file - by El Forum - 07-18-2008, 02:00 PM
Super .htaccess file - by El Forum - 07-18-2008, 02:41 PM
Super .htaccess file - by El Forum - 07-19-2008, 12:16 PM
Super .htaccess file - by El Forum - 07-22-2008, 08:15 AM
Super .htaccess file - by El Forum - 07-25-2008, 09:24 AM
Super .htaccess file - by El Forum - 07-25-2008, 09:53 AM
Super .htaccess file - by El Forum - 07-26-2008, 12:01 AM
Super .htaccess file - by El Forum - 07-26-2008, 08:18 AM
Super .htaccess file - by El Forum - 07-29-2008, 05:38 AM
Super .htaccess file - by El Forum - 07-29-2008, 11:25 AM
Super .htaccess file - by El Forum - 08-01-2008, 07:03 PM
Super .htaccess file - by El Forum - 08-04-2008, 10:18 AM
Super .htaccess file - by El Forum - 08-07-2008, 03:42 PM
Super .htaccess file - by El Forum - 08-07-2008, 03:53 PM
Super .htaccess file - by El Forum - 08-07-2008, 08:01 PM
Super .htaccess file - by El Forum - 08-25-2008, 03:39 AM
Super .htaccess file - by El Forum - 08-25-2008, 08:50 AM
Super .htaccess file - by El Forum - 08-25-2008, 10:06 AM
Super .htaccess file - by El Forum - 08-25-2008, 10:13 AM
Super .htaccess file - by El Forum - 08-25-2008, 10:30 AM
Super .htaccess file - by El Forum - 11-05-2008, 02:06 PM
Super .htaccess file - by El Forum - 01-30-2009, 10:19 AM
Super .htaccess file - by El Forum - 02-04-2009, 11:00 AM
Super .htaccess file - by El Forum - 02-04-2009, 02:27 PM
Super .htaccess file - by El Forum - 02-04-2009, 02:59 PM
Super .htaccess file - by El Forum - 02-05-2009, 04:25 PM
Super .htaccess file - by El Forum - 04-13-2009, 03:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB