R
R
Ruslan2022-02-18 11:04:02
htaccess
Ruslan, 2022-02-18 11:04:02

How to write htaccess for VPS server on Debian 10?

Hello!
I'm trying to run a website on a VPS server (Debian 10). The root directory is /var/www/html. It contains a standard index.html file from apache2, it is launched by ip-address. But when I upload my index.php, it doesn't open.
At first he gave a 500 error with my .htaccess.

I registered AllowOverride All in the 000-default.conf file, which is located in apache2/site-available/

, it started to run, but not at the url that is needed. That is, I need 45.45.45.45/admin/ , where admin is the controller, and it redirects to an address like https://45.45.45.45/?controller=admin and writes the connection attempt failed. This https appears from somewhere, although it does not appear anywhere in htaccess. If from the same addresshttps://45.45.45.45/?controller=admin I remove https, then it opens normally. But I need exactly this kind - 45.45.45.45/admin/
Here is the code of the .htaccess file

AddDefaultCharset UTF-8

  Options +FollowSymLinks
    Options -Indexes
    DirectoryIndex index.php

    RewriteEngine On
    RewriteBase /

 RewriteRule ^([a-z]+)/([a-z]+)/([0-9]+)/$ /?controller=$1&action=$2&id=$3&%{QUERY_STRING} [NS,L]
 RewriteRule ^([a-z]+)/([a-z]+)/$ /?controller=$1&action=$2&%{QUERY_STRING} [NS,L]
 RewriteRule ^([a-z]+)/([A-Za-z0-9-_]+).html$ /?controller=$1&graphname=$2&%{QUERY_STRING} [NS,L]
 RewriteRule ^([a-z]+)/([a-z]+)/([A-Za-z0-9-]+).html$ /?controller=$1&action=$2&batthelpredact=$3&%{QUERY_STRING} [NS,L]
 RewriteRule ^([a-z]+)/([0-9]+)/$ /?controller=$1&id=$2&%{QUERY_STRING} [NS,L]
 RewriteRule ^([a-z]+)/$ /?controller=$1&%{QUERY_STRING} [NS,L]

php_flag display_errors on

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Drno, 2022-02-18
@kuchuluk

https appears because of the browser. I have such garbage in chrome, in mozilla it's normal...
for the rest - you need to look at the web server settings
And I hope after uploading the files to /var/www/html did you give the web server the rights to the files?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question