M
M
Mitya ToDaSyo2019-06-25 06:05:08
htaccess
Mitya ToDaSyo, 2019-06-25 06:05:08

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_htmla 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

2 answer(s)
M
Mitya ToDaSyo, 2019-06-25
@dimastik1986

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

I ask the representatives of the community who have delved into the topic%) to look at the file I compiled for the adequacy of what was written! Thank you!

V
Viktor Taran, 2019-06-25
@shambler81

you just had to change the DocumentRoot to the site and that's it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question