Intereting Posts

.htaccess переписать путь к пути к папке

У меня есть контакт подкаталога и внутри contact.php и contact_content.php и .htaccess файл

В файле .htaccess у меня есть следующий код:

Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/contact/contact.php RewriteRule ^ /contact [R=301,L] RewriteRule ^/$ contact.php [NC,L,END] # deny access RewriteRule ^(contact_content)\.php - [F,L,NC] 

Отказать в доступе и первом правиле перезаписи работать отлично, но проблема в том, что вторая перезапись -> когда я перехожу к localhost/contact Мне показан список файлов в каталоге контактов, а не сайт contact.php

Надеюсь, это сработает.

 RewriteEngine On Options -Indexes RewriteCond %{REQUEST_URI} contact\.php$ RewriteRule ^(.*)$ /contact [R=301] RewriteCond %{REQUEST_URI} ^/contact/?$ RewriteRule ^(.*)$ /$1/contact.php [L,QSA,END] RewriteRule ^(contact_content)\.php - [F,L,NC] 

Это работает для меня -> измененный ответ Сахил Гулати

 Options +FollowSymLinks -Indexes RewriteEngine On RewriteCond %{REQUEST_URI} ^/contact/contact.php RewriteRule ^ /contact [R=301,L] RewriteCond %{REQUEST_URI} ^/contact/?$ RewriteRule ^(.*)$ /contact/contact.php [L,QSA,END] RewriteRule ^(contact_content)\.php - [F,L,NC]