0

I have a CakePHP app that has some html static files in webroot. HTML files are in some directories like webroot/dir1/dir2/page.html. When I enter url: site.com/dir1 I get redirected to site.com/webroot/dir1/ but when I enter site.com/dir1/ I get redirected to the first page site.com And If I enter url for the html file: site.com/dir1/dir2/page.html I get redirected to the first page site.com. It supposed to show the html file. How can I make it show html file and not redirect to first page?

In my public_html the htaccess is:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

In the webroot the htaccess is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
s_puria
  • 397
  • 1
  • 8
  • 19

2 Answers2

1

It's definitely not connected to CakePHP. Just ignore your directory / ies that should not be processed by CakePHP's routing system, see this related SO post.

Insert .htaccess into your directory/ies that should be ignored:

RewriteEngine Off
Community
  • 1
  • 1
jnemecz
  • 3,171
  • 8
  • 41
  • 77
  • in all of them and subdirectories? – s_puria Feb 04 '17 at 20:55
  • You don't have to, `.htaccess` works hierarchically, it will be enough in parent repository. – jnemecz Feb 04 '17 at 20:57
  • Added the htaccess. still not working. Address is still processed by cakephp – s_puria Feb 04 '17 at 21:05
  • It seems like a mess. What is your `public_html` directory, where it comes from? Is this a directory where are placed your directories with static content? If so, place .htaccess file into this directory. If it is not, you should provide more information about your directory structure. – jnemecz Feb 04 '17 at 21:27
  • Its in a cpanel with a home directory and public_html subdirectory of home. the webroot dir is in public_html and static files folder in the webroot directory home >public_html >webroot>static_dir1>static_dir2>static_dir3>page.html – s_puria Feb 04 '17 at 21:40
0

your questions isn't about php, it's about the apache Webserver or more about -> Apache Module mod_rewrite

Rewrite Engine is only called one time, so you have to put all changes in one File.

kind regards set

set-wrong
  • 11
  • 1