bizley / timeclock

Simple work time clocking service
MIT License
30 stars 11 forks source link

enablePrettyUrl "404 NotFound" #61

Closed maquibo86 closed 1 year ago

maquibo86 commented 1 year ago

Hi, I'm having issues if I leave "'enablePrettyUrl' => true," I have to set it to "false" for the application to work. I've enabled mod_rewrite, and I've created an htaccess file inside the public folder with the following code:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule ^(.*)$ index.php/$1 [L]

I've also tried with the following htaccess and it doesn't work either:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

In the Apache virtualhost, I've added the following:

<Directory />
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
    Allow from all    
</Directory>

I can't think of any other ideas. Can you help me? Thank you very much. PS: If I set enablePrettyUrl to false, it works fine.

maquibo86 commented 1 year ago

I've solved it with the following code according to the guide "https://www.yiiframework.com/doc/guide/2.0/en/start-installation#configuring-web-servers"

<Directory />
            DirectoryIndex index.php
            AllowOverride All
            Order allow,deny
    Allow from all  
        RewriteEngine on

    # if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
        RewriteRule ^index.php/ - [L,R=404]

        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d

        # Otherwise forward the request to index.php
        RewriteRule . index.php
</Directory>

Thank you very much