[Note] Cấu hình vhost cho phép đọc htaccess

Table of Contents

wordpress vào thì nó không đọc được file htaccess, nên không rewrite url được. https://dothanhlong.org/note-tro-domain-ve-lop-mang-sau-nat-multi-vps-multi-local-ip/ Lỗi này dẫn đến việc thay vì để url dạng

https://dothanhlong.org/?page=about
Mà rewrite để thành
https://dothanhlong.org/about
thì nó sẽ hiểu about là một thư mục chứ không phải một tham số từ wordpress, đẫn đến báo lỗi 404.

Cách khắc phục không đọc được htaccess

Khai báo dòng sau vào cấu hình vhost
AllowOverride All
Cụ thể một vhost của mình sẽ như thế này
NameVirtualHost *:80 <Directory "C:/xampp/htdocs/"> AllowOverride All Order Deny,Allow Allow from all </Directory> <VirtualHost *:80> DocumentRoot "D:/WebData/hahahaha/" ServerName hahahaha.com ErrorLog "logs/hahahaha.com-error.log" CustomLog "logs/hahahaha.com-access.log" combined <Directory "D:/WebData/hahahaha/"> AllowOverride All # Order Allow,Deny Allow from all # --New way of doing it Require all granted #Options FollowSymLinks Includes ExecCGI #RewriteEngine On #RewriteBase / #RewriteRule ^index\.php$ - [L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule . /index.php [L] </Directory> </VirtualHost>
Kiểm tra thì wordpress đã đọc được file htaccess Done! -soiqualang_chentreu-]]>

Leave a Reply

Your email address will not be published. Required fields are marked *