Post by liuhu1985 » Wed Mar 05, 2025 7:23 am

I using Caddy 2.8.4 + PHP 8.3.17 + MySQL 8.0.41 + OpenCart 4.1.0.0, but SEO URLs are not working no matter how can I configure them. The issue is:
• Only the homepage loads correctly.
• All other pages either return 404 or fail to recognize the SEO URL.

my Caddyfile rewrite rule is:

Code: Select all

@notStatic {
  not path *.jpg *.jpeg *.png *.gif *.webp *.ico *.css *.js *.svg *.woff *.woff2 *.ttf *.eot
  not path /image/* /system/* /assets/* /admin /admin/*
  not file {path}
}
rewrite @notStatic /index.php?_route_={uri}
Use curl -I to access, status code 200.
my expect Caddy to correctly process SEO-friendly URLs, but it doesn’t seem to be working. How can this be fixed?

Newbie

Posts

Joined
Sun Mar 02, 2025 4:21 pm

Post by by mona » Wed Mar 05, 2025 6:20 pm

OC4 is not recommended in any version for production sites.
It has a lot of bugs and is not stable.
The recommended stable OC version is 3.0.4.0 which can be downloaded here => https://www.opencart.com/index.php?rout ... ad/history

More information is needed. You have not mentioned if you set SEO urls in settings. If you have SEO urls entered.
For more information on how to set up SEO urls you can see the documentation => https://docs.opencart.com/en-gb/administration/seo/
Or search google => https://www.google.com/search?q=how+to+ ... n+Opencart

I have never used Caddy and you might be better asking here => https://caddy.community/

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by JNeuhoff » Wed Mar 05, 2025 10:21 pm

You need to implement this Apache .htaccess equivalent in Caddy:

Code: Select all

## SEO URL Settings
RewriteEngine On
## If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
## Rewrite Rules
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|webp|js|css|svg)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Please post in the Caddy forum for help.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by liuhu1985 » Thu Mar 06, 2025 10:43 pm

{
# Ensure Coraza WAF loads first (commented out)
# order coraza_waf first
}

https://xxxcom, https://www.xxx.com {
# Access log configuration
log {
output file /var/log/caddy/access.log {
roll_size 10MB
roll_keep 3
roll_keep_for 720h
}
format json
level INFO
}

# Website root directory
root * /var/www

# Coraza WAF configuration (commented out)
# coraza_waf {
# include /etc/caddy/coraza/coraza.conf
# include /etc/caddy/coreruleset/crs-setup.conf
# include /etc/caddy/coreruleset/rules/*.conf
# directives `
# SecRuleEngine On
# SecAction "id:900200,phase:1,nolog,pass,t:none,setvar:tx.anomaly_score_blocking=5"
# SecRule REQUEST_URI "^/superman" "id:1001,phase:1,pass,nolog,ctl:ruleEngine=Off"
# SecRule REQUEST_URI "^/index.php" "id:1002,phase:1,pass,nolog"
# SecUploadFileLimit 10485760
# `
# }

# Enable static file server
file_server

# Enable gzip compression
encode gzip

# Block access to system/storage/ directory
@block_storage {
path /var/storage/*
}
respond @block_storage "403 Forbidden" 403

# Ensure static assets are served directly instead of being processed by PHP
@static_files {
path_regexp /\.(ico|gif|jpg|jpeg|png|webp|js|css|svg)$
}
handle @static_files {
root * /var/www
file_server
}

# SEO-friendly URL rewrite rules
@rewrite {
not path /admin*
not path /image*
not path /catalog/view/theme*
not path /system*
not path /robots.txt
not path /sitemap.xml
not path /favicon.ico
not path /index.php
}
rewrite @rewrite /index.php?_route_={path}

# Ensure the request checks for static files before passing to PHP
try_files {path} {path}/ /index.php?{query}

# PHP processing
php_fastcgi unix//run/php/php8.3-fpm.sock

# TLS certificate management
tls {
issuer acme
}
}Thanks for your response! I’m still struggling with this part. Could you help modify the code?

Newbie

Posts

Joined
Sun Mar 02, 2025 4:21 pm

Post by rusy658 » Thu Mar 20, 2025 5:30 pm

can u pls explain me more e-zpassnh com

Newbie

Posts

Joined
Thu Mar 20, 2025 5:28 pm

Post by paulfeakins » Fri Mar 21, 2025 7:17 pm

liuhu1985 wrote:
Wed Mar 05, 2025 7:23 am
I using Caddy 2.8.4 + PHP 8.3.17 + MySQL 8.0.41 + OpenCart 4.1.0.0
OpenCart 4.1.0.2 has just been released, it *may* fix the issue?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 8 guests