Sunday, April 26, 2009

CakePHP configuration or .htaccess?

I have developed a Cake-application for the first time and now I am
about to put it up in a shared environment running FreeBSB with
apache2 as web server.

On the server, I have the directory
~user/public_html/

I have uploaded the cake application to the public_html-directory so
now do my file structure look like:
~user/public_html/cake /* The cake core */
~user/public_html/appname
|-config
|-controllers
|-...
\-webroot

After some work with .htaccess, I have been able to access my
application directly via
http://www.mydomain.com/
(~user/public_html
is pointing to appname/webroot via a RewriteRule
in .htaccess)

So far so good!

Now to my problem. In any link generated by cake the URL includes the
"appname", e.g. I have a link to "about" which says
http://www.mydomain.com/appname/about
and the same information is accessable via
http://www.mydomain.com/about

From an estetical point of view, the latter is preferred. I would like
to remove the appname from all links generated in my application since
there is no benefit having that information in there.

I have tried some RewriteRules and I have also tried to solve it in
the application configuration by setting App.baseUrl to '/'. The
latter is removing the appname from the links and everything seems to
work, but then login is not working any longer. (I am using the Auth-
component for authentication, no rocket-science there...).

The .htaccess file in ~user/public_html looks like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ appname/webroot/ [L]
RewriteRule (.*) appname/webroot/$1 [L]
</IfModule>

The .htaccess file in ~user/public_html/appname looks like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>

and the .htaccess file in ~user/public_html/appname looks like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /appname/webroot
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>


My question now, is my problem a cake-configuration problem or could I
solve my problem via .htaccess-instructions? Any suggestion in the
right direction is very much appreciated.

TIA,
Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: