Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8503961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:53:51+00:00 2026-06-11T01:53:51+00:00

I have following .htaccess file for my CakePHP 2 website. I put this under

  • 0

I have following .htaccess file for my CakePHP 2 website.
I put this under webroot folder.

Everyday some bots try to login to my site as a wordpress site. So I need to restrict some file names (wp-login.php) or some directories like Administrator or Cache.

  • But when I enter to example.com/wp-login.php I get “Error: An Internal Error Has Occurred.” page of CakePHP exception.
  • When I uncomment “directory /administrator” or “directory/cache” every page gives a 403 error.

How can I restrict to that files and folders?

<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
 Order allow,Deny
 Deny from all
</FilesMatch>

<Files wp-login.php>
  Order allow,deny
  Deny from all
</Files>

#<Directory /Administrator>
#    Order allow,deny
#    Deny from all
#<Directory>

#<Directory /Cache>
#    Order allow,deny
#    Deny from all
#<Directory>


<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

#set file cache maximum age in seconds
<ifmodule mod_headers.c>
    <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
        Header set Cache-Control "max-age=518400, public"
    </filesmatch>
    <filesmatch "\.(js|css)$">
        Header set Cache-Control "max-age=604800, public"
    </filesmatch>
</ifmodule>


# gzip files
<ifModule mod_gzip.c>
  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
  mod_gzip_item_include handler ^cgi-script$
  mod_gzip_item_include mime ^text/.*
  mod_gzip_item_include mime ^application/x-javascript.*
  mod_gzip_item_include mime ^application/javascript.*
  mod_gzip_item_exclude mime ^image/.*
  mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

# gzip files
<ifModule mod_deflate.c>
  <filesMatch "\.(css|js|x?html?|php)$">
    SetOutputFilter DEFLATE
  </filesMatch>
</ifModule>

Edit: I changed redirection code to this. Directory problem solved but CakePHP style Interval server error exception is still exists.

<FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
Order allow,Deny
Deny from all
</FilesMatch>

<Files "wp-login.php">
  Order allow,deny
  Deny from all
</Files>

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    RewriteRule ^/?(administrator|cache|undefined) - [L,F,NC]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:53:52+00:00Added an answer on June 11, 2026 at 1:53 am

    You can’t use the <Directory> blocks inside an htaccess file. I’m not sure why you get a 500 error for wp-login.php, but you need to add some quotes to the declaration:

    <Files "wp-login.php">
      Order allow,deny
      Deny from all
    </Files>
    

    You can place individual htaccess files in the Administrator and Cache directories that are just:

    Order allow,deny
    Deny from all
    

    Or you can use something like a rewrite rule:

    RewriteRule ^/?(Administrator|Cache) - [L,F]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have website which works fine and have following in the htaccess file RewriteEngine
I have codeigniter installed in root/igniter folder. under root/igniter, I have the following .htaccess
I have the following .htaccess file in a directory: RewriteEngine On RewriteCond %{HTTPS} !=on
So I have the following .htaccess file contents from my other project which is
I have the following in my .htaccess file: SetEnvIf Host ^example\.com$ myvar=1 <IfDefine myvar>
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works
I have the following in a .htaccess file as a test: RewriteEngine on RewriteRule
In my .htaccess file I have defined following rule, RewriteRule t/([^.]+)/$ /videos/tag.php?tag=$1 [QSA] The
In my .htaccess file i have the following re-write rule RewriteRule ^([a-z]*)$ work.php?album=$1 [L]
I have the following rule in my current .htaccess file to redirect /videos/login/ requests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.