Jump to content


Photo

Blocking access to admin Codeigniter panel via .htaccess

htaccess codeigniter

  • Please log in to reply
1 reply to this topic

#1 fluidsharp

fluidsharp

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 09 November 2013 - 03:12 PM

Hi,

How to block access to http://domain.com/admin/main/ admin panel via htaccess ?

I tried like below, but it is not working.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]

RewriteCond %{REMOTE_ADDR} ^1\.1\.1\.1$
RewriteRule /admin/main [F,L]

 



#2 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,666 posts
  • LocationMississauga, Canada

Posted 21 November 2013 - 06:04 AM

Assuming, the root web tree structure is like:

 

/ - web root

 

/admin

 

/admin/main

 

Put in next code inside /admin directory. 

RewriteEngine on
RewriteBase /admin/
RewriteRule ^\/?main\/.*$ - [F,NC]

You can also specify which type of files do not allow to be called:

RewriteEngine on
RewriteBase /admin/
#RewriteRule ^\/?main\/.*$ - [F,NC]
RewriteRule ^\/?main\/.*\.(jpg|jpeg|gif|png|bmp|php|pl)$ - [F,NC]

Edited by jazzman1, 21 November 2013 - 06:06 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com