craftcms / craft

Composer starter project for Craft CMS.
https://craftcms.com
BSD Zero Clause License
188 stars 91 forks source link

Add "RewriteBase /" to .htaccess file #52

Closed piotrpog closed 4 years ago

piotrpog commented 4 years ago

On one of the servers i installed Craft, subpages didnt opened (only index.php) unless I added RewriteBase / to .htaccess file.

Maybe this should be added to default Craft .htaccess file?

brandonkelly commented 4 years ago

Should work fine without it. Can you compare your .htaccess file to this one? Specifically make sure that the RewriteRule line doesn’t have any /s in yours.

OldStarchy commented 4 years ago

I also had trouble with this on wamp, I had to use this to get it working

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
angrybrad commented 4 years ago

RewriteBase is only necessary for hosting environments using Apache where you'd need to adjust the path that mod_rewrite prefixed to the result of a RewriteRule, which is definitely the edge case, not the norm.

https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase https://stackoverflow.com/questions/21347768/what-does-rewritebase-do-and-how-to-use-it

Going to go ahead and close this as it shouldn't be the default, but I do think we should have a support article on this for the times it comes up though. Have made a note to get that added.

OldStarchy commented 4 years ago

Yes i agree with what you've said @angrybrad, my knowledge on this is slim and unfortunately my "fix" doesn't work on the other developers machines so I have to figure something else out... :(

OldStarchy commented 4 years ago

Without it, I just get an "internal server error" with no other information (logs are empty too), so I guess its redirecting infinitely, but the [L] should prevent that so i'm really not sure why its not working.

OldStarchy commented 4 years ago

It seems to be impossible to get craft working without adding RewriteBase / when running in WAMP. For now i'm going to give up since there's only so much time in a day, but if anyone has any ideas I'd love to hear them.