How to override htacess file config (apache)

1. Output of caddy version:

V2 Latest

2. How I run Caddy:

I run caddy as a server

a. System environment:

Docker on QNAP

d. My complete Caddy config:

Caddy file

{
http_port 8080
https_port 8443
}

www.example.com {

redir https://example.com{uri}
}
example.com {
root * /www/
encode gzip
php_fastcgi 127.0.0.1:9000
file_server

}

3. The problem I’m having:

I am trying to run fancy url on my website and remove ?id= from the url with multilevel pages that it is like this:

https://example.com/index.php?id=page

And I would like to run it like this

https://example.com/page
or
https://example.com/page/page1 etc...

When fancy url are turned on, the link does go the the page, like this https://example.com/page/, but the website content does not change to the content of page

4. What I already tried:

I have tried everything, all rewrite options, redirect options on the caddy documentation, everything on this forum, but nothing seems to work.

My htaccess file rewrite rules
RewriteBase /

  • RewriteCond %{REQUEST_FILENAME} !-f*
  • RewriteCond %{REQUEST_FILENAME} !-d*
  • RewriteRule /?([A-Za-z0-9_-]+).html$ index.php?id=$1 [QSA,L]*

5. Links to relevant resources:

http://get-simple.info/wiki/how_to:website_settings#custom_permalink_structure

Caddy is not Apache. .htaccess rules don’t work with Caddy. That’s an Apache thing.

To make that work, then you should change your PHP app to read from $_SERVER['REQUEST_URI'] which will have the original URL as Caddy received it, then your PHP app can decide how to route the request.

Well, thanks for the response. But I don’t know what to do because all the requests from the CMS that I use have $_SERVER[‘REQUEST_URI’] on their main php files.

This topic was automatically closed after 30 days. New replies are no longer allowed.