Just for explanation - I think the following happened:

Your original htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

This means that
- if the requested file is not a directory (RewriteCond %
{REQUEST_FILENAME} !-d)
- and if the requested file is not a file (RewriteCond %
{REQUEST_FILENAME} !-f)
- then apply the rewrite rule to send everything to htaccess
(RewriteRule ^(.*)$ index.php?url=$1 [QSA,L])

Problem:
The url 'localhost' maps to a directory for apache, so the rewrite
rule was never applied.

Then you added a silly rewrite rule to your htaccess:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^silly\.html$ /exists.html [L]
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

A rewrite condition always applies just to the first rewrite rule that
comes after the condition(s),
so now the conditions were only applied to the silly rewrite rule.
That again means that everything was now directed to the index.php,
also your pictures and css files.

Now you added index.php as DirectoryIndex. This means that whenever
you supply a directory
without a filename in the url, apache looks for the file index.php in
this directory. So if you now request
http://localhost, the rewrite rule still will not apply, but as apache
uses the index.php anyway,  this does not matter.

When you request any cake url like http://localhost/foo, the rewrite
condition evaluates to true
(as the directory foo is neither a directory nor a file) and thus the
rewrite rule is applied.


Hope it helps you understand what was actually going on.

Claudia


On Jul 11, 3:05 pm, Hitsugaya <[EMAIL PROTECTED]> wrote:
> Hey there, im been working on this problem for some time now and i
> solved it. It turns out mod_rewrite was working properly from the
> verry start accept somehow it is was not property sending me to the
> CakePHP mainpage onhttp://localhost/, i still get the directory
> listing.
>
> But when i dithttp://localhost/somethingi get a new page saying
> missing somethingcontroller. So i figured...euh...it...it..it´s
> working!! Only problem is that i got the directory listing. After some
> googling and searching the apache conf i fount the following:
> DirectoryIndex. entered index.php there and now all is working. Still
> don´t quite know why that change was needed but im not complaining
> since its working. Now i can finally start brushing up my PHP skills
> and doing some coding.
>
> I just thought i post the solution to support other starting people. I
> wanna thank everybody posting in this thread for helping out, hope is
> can return the favor sometime. Cheers!
>
> On 8 jul, 19:37, Hitsugaya <[EMAIL PROTECTED]> wrote:
>
> > I've been trying, yet again, to get mod_rewrite to work. Now i've gome
> > accros something that is to me (begin a apache AND mod_rewrite noob)
> > quite strange:
>
> > I have the following file:
> > C:/Program Files/Apache Group/Apache2/htdocs/cakePHP/app/
> > webroot/.htaccess with the following content:
> > <IfModule mod_rewrite.c>
> >     RewriteEngine On
> >     RewriteCond %{REQUEST_FILENAME} !-d
> >     RewriteCond %{REQUEST_FILENAME} !-f
> >     RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
> > </IfModule>
> > When i hithttp://localhost/iget a directory listing off: :/Program
> > Files/Apache Group/Apache2/htdocs/cakePHP/app/webroot
> > This i think means that mod_rewrite is not functioning correclty.
>
> > BUT, now comes the crazy thing: when i change the file to:
>
> > C:/Program Files/Apache Group/Apache2/htdocs/cakePHP/app/
> > webroot/.htaccess with the following content:
> > <IfModule mod_rewrite.c>
> >     RewriteEngine On
> >     RewriteCond %{REQUEST_FILENAME} !-d
> >     RewriteCond %{REQUEST_FILENAME} !-f
> >     RewriteRule ^silly\.html$ /exists.html [L]
> >     RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
> > </IfModule>
>
> > I've added a second rewrite rule wich is a dummy rule (it makes
> > absolutely no sense :P) BUT when i now hithttp://localhost/iget my
> > CakePHP mainpage!!!
>
> > That indicates that mod_rewrite now is working. However, with this
> > little hack all images and styles dissapear. I googled it and i think
> > a .htaccess file can only have one rewrite rule.
> > Then howcome that the .htaccess file finally does what i needs to do
> > when i add a second rewrite rule? I think that something is wrong with
> > that file but i don't know what.
>
> > Help would be GREATLY appriciated!
>
> > On 8 jul, 14:38, Hitsugaya <[EMAIL PROTECTED]> wrote:
>
> > > I think they are. Just to be sure...there are .htaccess files in:
>
> > > C:/Program Files/Apache Group/Apache2/htdocs/cakePHP (the root folder
> > > of cakePHP). Content:
> > > <IfModule mod_rewrite.c>
> > >    RewriteEngine on
> > >    RewriteRule    ^$ app/webroot/    [L]
> > >    RewriteRule    (.*) app/webroot/$1 [L]
> > > </IfModule>
>
> > > C:/Program Files/Apache Group/Apache2/htdocs/cakePHP/app. Content:
> > > <IfModule mod_rewrite.c>
> > >     RewriteEngine on
> > >     RewriteRule    ^$    webroot/    [L]
> > >     RewriteRule    (.*) webroot/$1    [L]
> > >  </IfModule>
>
> > > C:/Program Files/Apache Group/Apache2/htdocs/cakePHP/app/webroot
> > > <IfModule mod_rewrite.c>
> > >     RewriteEngine On
> > >     RewriteCond %{REQUEST_FILENAME} !-d
> > >     RewriteCond %{REQUEST_FILENAME} !-f
> > >     RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
> > > </IfModule>
>
> > > All are left untouched, and the content seemes allright...
>
> > > Tnx for the relpy´s so far guys, hope we can solve this issue!
>
> > > On 8 jul, 13:44, "Jonathan Snook" <[EMAIL PROTECTED]> wrote:
>
> > > > Did the .htaccess files get copied properly?
>
> > > > > Jonathan // Im sure that the directory is my local cakephp. But the
> > > > > wierd thing is that withhttp://localhost/igetadirectory listing
> > > > > and the index.php file is in that directory. That should point to
> > > > > mod_rewrite not being enabled but when i fire up phpinfo it states
> > > > > that mod_rewrite is one of the loaded modules.- Tekst uit 
> > > > > oorspronkelijk bericht niet weergeven -
>
> > > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit 
> > > > oorspronkelijk bericht niet weergeven -
>
> > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk 
> > > bericht niet weergeven -
>
> > - Tekst uit oorspronkelijk bericht weergeven -
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to