I want to have these rules:
- /string-smth matches index.php?param=string-smth
- /some-file-with-dashes matches some-file-with-dashes.php
- /some-file-with-dashes.php remove .php extension extension
- index.php redirects to /
This works on my local machine but not on the server. Are there some options/flags or other things for apache config perhaps that need to be changed to support this?
This is my current .htaccess file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1 [QSA,NC,L]
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=302,L]
On my local machine this works, except for rule #3 (which I have not implemented in .htaccess)
On my server (digital ocean, ubuntu):
- https://karta-hrvatske.com.hr/zagreb is matched (rule #1)
- https://karta-hrvatske.com.hr/auto-karta-hrvatske.php opens the file
- https://karta-hrvatske.com.hr/auto-karta-hrvatske responses with 404