CakePHP and .htaccess in shared hosting environment


CakePHP and .htaccess in shared hosting environment



Greetings!

I have CakePHP based app on shared hosting I wonder if there's a way to clean up the url through .htaccess. What bugs me is that I have to have index.php in it or I get a 404:

project.com/index.php/controller/method

Initially I was getting a 404 error no matter what and my host admin ended up setting RewriteEngine off and this is what it looks like now

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

Is there fix for this without the .htaccess? As it is right now, does it pose any type of security risk?

Thanks




htaccess for www-only redirection

1:



.htaccess redirect problem
You need three .htaccess files :.
Redirect 301 & Mod Rewrite Issues
  • /.htaccess
  • /app/.htaccess
  • /app/webroot/.htaccess
If the one you pasted in your question is the one at the root of your website, that's probably where your problem comes from.


htaccess redirect question
These directives file would rewrite URLs to project.com/webroot/, which doesn't exist.


URL rewrite issues using .htaccess
It should redirect to project.com/app/webroot/, which will in turn rewrite to index.php?url=$1 (relative to project.com/app/webroot/)..
.htaccess redirect all files in one folder to exact same in another folder
I'm not pasting the files here; the three of them are available in the CakePHP releases as well as in the Book: http://book.cakephp.org/2.0/en/installation/url-rewriting.html (check the 3rd item in the page)..
.htaccess, proper rewriting of directory and file with same name


mod_rewrite send everything not matched to a rewritemap

2:


Are you sure the mod_rewrite module is enabled on your shared hosting?.



70 out of 100 based on 70 user ratings 1120 reviews