Installing/Setting cakePHP on Server - cakephp-2.0

I'm trying to setup my cakephp work on server
Purchased godaddy shared server
when i go to my site http://xyz.com/cake/
I'm getting 404 error
The requested URL /xyz/cake/app/webroot/ was not found on this server.
anyhelp plz ??
Thanks,
Satish

You need to set the correct RewriteBase in your .htaccess if you're going to run Cake inside a subdirectory.
Both /xyz/cake/.htaccess and /xyz/cake/webroot/.htaccess (assuming /xyz/cake is the path to Cake and your app dir) need to be updated.
/xyz/cake/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /xyz/cake/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/xyz/cake/webroot/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /xyz/cake/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

Related

what should I put in the .htaccess file to deploy my site on hostinger?

I'm deploying my first project on Hostinger. It's a React app created according to the basic config given on reactjs.org. I have uploaded my entire folder to the server via FileZilla and am now trying to configure my .htaccess file but I am only getting 500 errors back. I put this file in my folder called react-portfolio but nothing works. The whole project is stored in the react-porfolio folder.
here is what I tested first
DirectoryIndex /react-portfolio/public/index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ react-portfolio/public/$1 [L]
</IfModule>
here is the second file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Thank you

Wordpress Apache RewriteRule

I would like to redirect the Facebook crawlers to a static page, since my website is in AngularJS and I need to work with the og:meta. I'm using Wordpress as back-end, so at the moement this is my .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I tryed to add these two lines:
RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet)
RewriteRule tracks/(\d*)$ http://<path>/static.php [P]
But this is not working. If I try to scrape a page with the facebook tool (https://developers.facebook.com/tools/debug/) I'm not redirect to the static page.
Keep in mind that in wordpress my permalinks are build in this way: http://<fqdn>/%category%/%postname%/ and tracks/ is one of my category.
The solution was to exclude the facebook crawler from the default 302 of wordpress.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/1.1
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/1.1
RewriteRule (.*) http://<dn>/static.php [L]
</IfModule>

How to remove index.php from url in cakephp 2

I have tried commenting this line present in congif/core.php,
// Configure::write('App.baseUrl', env('SCRIPT_NAME'));
But when I hit my url it gives me 404 error.
Make sure you are loading mod_rewrite correctly. You should see something like
#uncomment it by removing leading #
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Verify that your .htaccess files are actually in the right directories. Some operating systems treat files that start with ‘.’ as hidden and therefore won’t copy them.
#CAKEPHP root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
#Cakephp App directory .htacess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
#Cakephp webroot directory .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
URL_REWRITING
You may fix it with your web-sersver (.htaccess rules for apache, rules in configuration file for nginx).

Angular 2 app on Apache server

I have an angular 2 app served on Angular 2. On the host, it is located at the document root and everything is working fine. I have an .htaccess file with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
Problem:
On my laptop, i have an Apache server (xampp) with document root as "
c:\users...\WebProjects
When i develop the site, i put the files in c:\users...\Projects\Projects1\dist
In this directory, i cannot get the website to work due to files/folders called not being in the root. ie Server is trying to load \css\app.css when it should be loading Projects1\dist\css\app.css
Can i write a specific .htaccess to be able to serve the app from that directory? (or something else without having to change the httpd.conf document root?)
thanks
you need to add the path in your .htaccess file and your index.html file like so:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your/path/here/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
In index.html, you need to update the base href aswell to reflect the path like so:
<base href="/your/path/here/">
And that should do the trick :)

My cakephp 2.2 site not working on subdomain

My cakephp 2x site working fine on my local machine.
But i have upload on sub domain server it is not working.
I want my cakephp site working on sub domain with admin Prefix
http://vertaxtechnology.com/ => is my domain
http://dev.vertaxtechnology.com/ = is my sub domain
http://dev.vertaxtechnology.com/eventapp = is my cake directory
This is my Root htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /eventapp/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my app htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /eventapp/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
This is my webroot htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Please help thanks

Resources