Answer the question
In order to leave comments, you need to log in
Folder for site pages, is it possible?
I think I've seen it somewhere, but I can't find it!
I would like to create a rule, if possible, that would allow me to put all the pages of the site in a separate folder, while the address bar remained unchanged.
For example, create a folder in public_html
a folder pages
At the same time, the path in the address bar was not like this site.ru/pages/index.php
But like thissite.ru/index.php
Answer the question
In order to leave comments, you need to log in
it seems to work, at least at first glance
RewriteRule ^$ /pages/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/pages/
RewriteRule ^(.*)$ /pages/$1.php
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^pages/(.*[^/])$ https://%{SERVER_NAME}/$1 [R=301]
RewriteEngine On
#Запрет просмотра папок
Options All -Indexes
#Выполнять код PHP в файлах HTML
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html .phtml
#Установка подключения по https
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
#Устанавливаем директорию по умолчанию
RewriteRule ^$ /pages/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/pages/
RewriteRule ^(.*)$ /pages/$1.php
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^pages/(.*[^/])$ https://%{SERVER_NAME}/$1 [R=301]
#Страницы ошибок
ErrorDocument 400 /tmpl/errorDocument.php
ErrorDocument 403 /tmpl/errorDocument.php
ErrorDocument 404 /tmpl/errorDocument.php
ErrorDocument 405 /tmpl/errorDocument.php
ErrorDocument 408 /tmpl/errorDocument.php
ErrorDocument 500 /tmpl/errorDocument.php
ErrorDocument 502 /tmpl/errorDocument.php
ErrorDocument 504 /tmpl/errorDocument.php
you just had to change the DocumentRoot to the site and that's it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question