views:

590

answers:

4

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

+1  A: 

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

RioTera
... good question, I'm not to be honest :-(
vector
If it's not, does that mean I'm stuck with it?
vector
Yes, you can check with phpinfo. Create a php file with this instruction inside and run it on your server:<?phpphpinfo ();?>
RioTera
... yes it it. Just found out from tech support (could not run the phpinfo() function; disabled for security reasons )
vector
did you ask if the mod_rewrite is installed?
RioTera
indeed, I asked and was told it's installed and running. So what are my options now?
vector
did you upload the right .htaccess also in the webroot?<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]</IfModule>
RioTera
+1  A: 

probably this answers - http://stackoverflow.com/questions/952999/fixing-cakephp-htaccess-modrewrite-for-shared-hosting-setups

Arpit Tambi
thanks for the tip, I looked at the question, but I'm afraid I'm out of luck without RewriteEngine on :-(
vector
+1  A: 

You need three .htaccess files :

  • /.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. These directives file would rewrite URLs to project.com/webroot/, which doesn't exist. It should redirect to project.com/app/webroot/, which will in turn rewrite to index.php?url=$1 (relative to project.com/app/webroot/).

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/view/37/Apache-and-mod%5Frewrite-and-htaccess (check the 3rd item in the page).

Xr
... thanks for the lead, I'll check into that as soon as can get to it.
vector
A: 

Do you know of anyway with htaccess to disable someone from using your domain to point to their own website on the same server? Ex: they use YOURDOMAIN.com to promote their PHISHING WEBSITE.COM by using this simple URL to send users : YOURDOMAIN.COM/~phishing/file.html

Any help would be greatly appreciated. Thanks

Roch
... not sure, but .htaccess doesn't come to mind as first line of defense against phishing attacks.
vector