Help Làm sao để xóa đc index.php

sanhpv

Corporal
Như tiêu đề mình có tải code web xenforo bản 2.1.8 của bác @PVS ở bài viết này HERE
và đọc các bài hướng dẫn để xóa cái index.php nhưng không làm được
tích vào ô Use full friendly URLs , trang chủ hiển thị bình thường mà bấm vào trang con và viết bài viết thì bị lỗi 404 hết
mình đang dùng vps websv là nginx , hiện tại trong file html , hiện đang có 2 file (1 là .htaccess , 2 là .txt) , mình đã thử xóa file .txt đi rồi mà vẫn bị lỗi 404 , mong cao nhân giúp đỡ
 
Bạn thử đổi tên htaccess.txt thành .htaccess nha. Backup bản .htaccess trước đó đề phòng sai sot.
 
Bạn thử đổi tên htaccess.txt thành .htaccess nha. Backup bản .htaccess trước đó đề phòng sai sot.
trong cái html đó có 2 file a ạ 1 file là htaccess.txt 2 là .htaccess
đây là đoạn code trong file .htaccess a xem qua đúng chưa ạ
Mã:
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

location /xf/install/data/ {
    internal;
}
location /xf/install/templates/ {
    internal;
}
location /xf/internal_data/ {
    internal;
}
location /xf/library/ { #legacy
    internal;
}
location /xf/src/ {
    internal;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
}
 
Bạn cứ làm theo hướng dẫn ở trên nhé.
đây a
Untitled.jpg
 
Nếu ghi đè được thì ghi đè nhé, còn không thì cứ download file .htaccess về máy để backup trước đề phòng, sau đó xoá file .htaccess trên server và đổi tên file htaccess.txt thành .htaccess
 
Nếu ghi đè được thì ghi đè nhé, còn không thì cứ download file .htaccess về máy để backup trước đề phòng, sau đó xoá file .htaccess trên server và đổi tên file htaccess.txt thành .htaccess
e đổi rồi không đc, a ạ , e nghĩ phần .htaccess naft dành cho apche
e dùng nginx , e xem bài hướng dẫn ở xenforo như thế này https://xenforo.com/xf2-docs/manual/options/#friendly-urls

dưới dây là đoạn code , e k biết bài hướng dẫn là thêm doạn code này vào .htaccess , hay ở đâu khác
Mã:
Nginx
To enable friendly URLs in Nginx, you must put the following in your server configuration:

location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

location /xf/install/data/ {
    internal;
}
location /xf/install/templates/ {
    internal;
}
location /xf/internal_data/ {
    internal;
}
location /xf/library/ { #legacy
    internal;
}
location /xf/src/ {
    internal;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
}
The /xf/ paths must be changed to match your XenForo installation path.

This configuration also helps protect web-based access to directories that aren't normally accessible.
và bên dưới nó chú thích thay /xf/ thành gì thì e cũng k hiểu thay /xf/ thành gì ,

a đọc qua chỉ giúp e với @PVS
 
Nếu là apache thì phải chạy lại máy chủ để nhận htacc mới. Mà mặc định chỉ cần như này thôi

Mã:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to workaround HTTP Basic auth issues when using PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
 
Nếu là apache thì phải chạy lại máy chủ để nhận htacc mới. Mà mặc định chỉ cần như này thôi

Mã:
<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to workaround HTTP Basic auth issues when using PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
đã chuyển sang apache khởi động các kiểu vẫn không hết lỗi 404 , chỉ vào đang trang chủ , k hiểu kiểu gì
 
Nếu ghi đè được thì ghi đè nhé, còn không thì cứ download file .htaccess về máy để backup trước đề phòng, sau đó xoá file .htaccess trên server và đổi tên file htaccess.txt thành .htaccess
Nginx có dùng .htaccess đâu mà đổi. Nếu dùng nginx thì xem lại cấu hình conf và version php nha
 
bận cấu hình nginx như thế nào. mình cũng gặp tương tự như bạn và cũng đã fix được
 
Back
Top