htmly icon indicating copy to clipboard operation
htmly copied to clipboard

404 Not Found after fresh install v2.8.1

Open camillo777 opened this issue 3 years ago • 10 comments

Hello, I did a fresh install of latest version v2.8.1, at the end of installation I got a 404 error. Uploaded zip, extracted and accessed http://mydomain/install.php; inserted data and go!

Page is redirected to:

http://mydomain/admin/content

But there is no admin/content folder, is there some rewrite url I have to add?

How to access this folder? http://mydomain/admin I cannot find any doc or config about this "admin" folder.

Apache Version: 2.4.46 PHP Version: 7.3.28

Thank you Camillo

camillo777 avatar Jun 08 '21 08:06 camillo777

Hello,

Yes it need mod_rewrite for apache, example config: https://docs.htmly.com/web-servers/apache

danpros avatar Jun 09 '21 03:06 danpros

Hello @danpros Thank you but in that page i do not see any mention at the rewrite module, something like this:

RewriteRule ^prodotto/([0-9]+)/$ /prodotti.php?codice=$1

I usually see this configuration in .htaccess file.

As an example, this is the rewrite configuration for Prestashop (that I barely understand...):

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums

<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

RewriteEngine on


#Domain: mydomain.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# Images
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^ps17.camillo.space$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/font-woff .woff
AddType font/woff2 .woff2
<IfModule mod_headers.c>
        <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg)$">
                Header set Access-Control-Allow-Origin "*"
        </FilesMatch>

    <FilesMatch "\.pdf$">
      Header set Content-Disposition "Attachment"
      Header set X-Content-Type-Options "nosniff"
    </FilesMatch>
</IfModule>

<Files composer.lock>
    # Apache 2.2
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>

    # Apache 2.4
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
</Files>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

camillo777 avatar Jun 09 '21 07:06 camillo777

@camillo777 The rewrite rules are in the .htaccess. Perhaps check if mod_rewrite is available / enabled. On ubuntu sudo a2enmod rewrite and then restart apache2.

ProjectPatatoe avatar Jun 12 '21 08:06 ProjectPatatoe

@camillo777 The rewrite rules are in the .htaccess. Perhaps check if mod_rewrite is available / enabled. On ubuntu sudo a2enmod rewrite and then restart apache2.

Yes I know, but don't know how to set them for htmly. Is htmly install php supposed to write them into .htaccess file or am I supposed to write them? And I don't find any docs explaining how to set them for htmly.

Prestashop for example automatically write them to .htaccess file.

Thank you

camillo777 avatar Jun 12 '21 08:06 camillo777

The default .htaccess already has rewrite enabled. The site definition will need "AllowOverride All" or something similar for the .htaccess to take effect. Are you able to post your site definition?

ProjectPatatoe avatar Jun 16 '21 10:06 ProjectPatatoe

Hello @ProjectPatatoe , this is my current .htaccess file:

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

camillo777 avatar Jun 16 '21 10:06 camillo777

is this .htaccess the one in the root of htmly? Have you tried using the default one first?

Could you share your site definition file from apache? On ubuntu this is located in /etc/apache/sites-enabled/whatever-site-used

ProjectPatatoe avatar Jun 21 '21 18:06 ProjectPatatoe

Hello, Sorry for the delay, I think I just need an example of Rewrite Rules for Apache, that's all. I see there is an example for Lighttpd, but not for Apache web server. Can anyone help? Thank you!

camillo777 avatar Sep 21 '21 14:09 camillo777

https://github.com/danpros/htmly/blob/master/.htaccess

I would suggest to try using the original .htaccess that is included first. Inside, it will enable the rewrite engine if it is available.

ProjectPatatoe avatar Sep 21 '21 16:09 ProjectPatatoe

Thank you @ProjectPatatoe I added this to my exisitng ".htaccess" file and indeed it seems to work! :-) I woyld suggest to add this hint to the "Web Server/Apache" docs. Thank you!

camillo777 avatar Sep 23 '21 09:09 camillo777

@ProjectPatatoe thanks for the follow up. I will close this one.

danpros avatar Dec 14 '23 14:12 danpros