1

I have a problem with this... I'm using free hosting for giving a demo to my future buyers of my own cms.

The hosting is hubuhost.com, they are supporting the last version of php 8.1. The problem is that they are on nginx and do not support my htaccess rules from apache.

My config is :

<IfModule mod_negotiation.c>
#Important rules for our system
Options -Multiviews -Indexes +FollowSymLinks
</IfModule>

#app.php instead of index.php
<IfModule mod_dir.c>
DirectoryIndex core.php index.php index.html
</IfModule>

#If 404 - redirect to 404 page
ErrorDocument 404 /404/index.php

<IfModule mod_rewrite.c>
#ModRewrite ON
RewriteEngine on 

#News SEO Urls
RewriteRule  ^topic_(.+?)$ core.php?id=$1

#Router
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ core.php [QSA,L]
 
#remove end trailing slash from urls
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(.*)/$
RewriteRule ^ /%1 [R=301,L]
</IfModule>

#Block ENV access
<IfModule mod_version.c>
<Files "config.env">
   Order allow,deny
    Deny from all
</Files>
</IfModule>

Can someone convert this to nginx ?

I try with some rules but without success. I don't know what to do... Demo pic from admin panel: https://i.ibb.co/gwZStXN/image.png

1
  • Aside: The Apache mod_rewrite rules are not in the correct order. The rule #remove end trailing slash from urls is not doing anything. This needs to go before the #Router.
    – MrWhite
    Mar 1, 2022 at 23:21

1 Answer 1

0

See if this will do the job

autoindex off;

index core.php index.php index.html;

error_page 404 /404/index.php;

location /topic_ {
  rewrite ^/topic_(.+?)$ /core.php?id=$1;
}

location / {
  if (!-e $request_filename){
    rewrite ^(.*)$ /core.php break;
  }
  if (!-e $request_filename){
    rewrite ^(.*)$ /%1 redirect;
  }
}

location /config.env {
  deny all;
}
2
  • thank you, but this is not supported by hosting (maybe), they allowed only a few rules....I will search for another free host provider.
    – pok4
    Mar 1, 2022 at 23:10
  • Welcome, what is the error you get? Mar 1, 2022 at 23:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .