Skip to content

Instantly share code, notes, and snippets.

@dizyart
Last active January 30, 2019 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dizyart/4733257 to your computer and use it in GitHub Desktop.
Save dizyart/4733257 to your computer and use it in GitHub Desktop.
.htaccess to allow subdirectory access parallel to a CakePHP app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:development|cgi-bin|v1\.5|phpMyAdmin)(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/(?:development|cgi-bin|v1\.5|phpMyAdmin)(?:$|/.*)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
@Shabasha
Copy link

Shabasha commented Jan 30, 2019

May be you are looking to access a subfolder in the same CakePHP Installation , by doing so , let's assume that you are trying to access phpMyAdmin in cakephp Root Folder where .htaccess exists ( in the Root Folder , where vendor exists and before moving to /app ) , the .htaccess will be as follows :

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

without doing so , when you type http://path_to_cakephp_root_folder_in_htdocs_or_www/phpMyAdmin , you will get a cakephp error page assuming that you are trying to access a controller named phpMyAdmin ...

With that update , when you type the same URL , you will get phpMyAdmin instead ...

Hopes it help ...

Sorry for the late answer and the bad english ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment