Help Cấu hình redirect cho file htaccess

Shu Sakamaki

Corporal
Tham gia
09/07/2015
Bài viết
104
Được Like
38
Mọi người giúp em cấu hình với ạ, forum em có chứng chỉ SSL và không dùng subdomain www.
Domain của forum em có dạng như thế này https://domain.com/forum thì cấu hình như nào là đúng ạ?
em cấu hình như dưới đây nhưng không có tác dụng gì :(
Mã:
#    Mod_security can interfere with uploading of content such as attachments. If you

#    cannot attach files, remove the "#" from the lines below.

#<IfModule mod_security.c>

#    SecFilterEngine Off

#    SecFilterScanPOST Off

#</IfModule>



ErrorDocument 401 default

ErrorDocument 403 default

ErrorDocument 404 default

ErrorDocument 405 default

ErrorDocument 406 default

ErrorDocument 500 default

ErrorDocument 501 default

ErrorDocument 503 default



<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
    RewriteCond %{HTTP_HOST} !^domain\.com/forum$ [NC]
    RewriteRule ^(.*)$ http://domain.com/forum/$1 [R=301,L,QSA]

    #    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 enable WebDAV editing with 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>
mong cao nhân nào đó giúp em.
 
  • Like
Reactions: THB

hacobi1102

MasterCorporal
Tham gia
10/03/2016
Bài viết
356
Được Like
166
Bạn cần nói rõ ý định hơn, chưa hiểu câu hỏi của bạn
 

duy13

Private
Tham gia
28/12/2016
Bài viết
10
Được Like
20
Mã:
#########################
# redirect www to no-www
#########################
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

#########################
# redirect port 80 to https (đã test):
# Always use https for secure connections
# Replace 'domain.com' with your domain name
# (as it appears on your SSL certificate)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R=301,L]
 

PVS

Super Moderator
Thành viên BQT
Tham gia
28/02/2015
Bài viết
16,735
Được Like
12,681
em làm như vậy mà không được
tên miền của em dạng domain.com/forum nhé
thì bạn chỉ việc thay theo như định dạng của diễn đàn là được nha
 

nghienvt

Gefreiter
Tham gia
01/01/2017
Bài viết
65
Được Like
65
Theo mình đoán thì server của bạn cấu hình sai trong httpd.conf, làm cho file .htaccess có mà cũng như không, nó không áp dụng.

Để kiểm tra có phải đúng là .htaccess không hoạt động thì bạn đưa vào file này dòng sau:
# disable directory browsing
Options All -Indexes

Rồi tạo một thư mục trống, ví dụ: https://domain.com/forum/test
Vào thử thư mục này, coi có hiển thị dạng "index of" không hay là báo lỗi không xem được. Nếu hiển thị dạng index of, thì đích thị là file .htaccess không được áp dụng rồi.

Phải vào chỉnh trong httpd.conf lại thành:

<Directory "/var/www/html">
AllowOverride All
Require all granted
</Directory>

Mình chỉ đoán thôi, và mong giúp được ý gì đó để bạn kiểm tra lại, vì đã từng dính vụ .htaccess có như không mà cứ tưởng nó đang hoạt động.
 

Shu Sakamaki

Corporal
Tham gia
09/07/2015
Bài viết
104
Được Like
38
Theo mình đoán thì server của bạn cấu hình sai trong httpd.conf, làm cho file .htaccess có mà cũng như không, nó không áp dụng.

Để kiểm tra có phải đúng là .htaccess không hoạt động thì bạn đưa vào file này dòng sau:
# disable directory browsing
Options All -Indexes

Rồi tạo một thư mục trống, ví dụ: https://domain.com/forum/test
Vào thử thư mục này, coi có hiển thị dạng "index of" không hay là báo lỗi không xem được. Nếu hiển thị dạng index of, thì đích thị là file .htaccess không được áp dụng rồi.

Phải vào chỉnh trong httpd.conf lại thành:

<Directory "/var/www/html">
AllowOverride All
Require all granted
</Directory>

Mình chỉ đoán thôi, và mong giúp được ý gì đó để bạn kiểm tra lại, vì đã từng dính vụ .htaccess có như không mà cứ tưởng nó đang hoạt động.
cảm ơn anh ạ :D
 

nhuttran913

Gefreiter
Tham gia
18/03/2017
Bài viết
93
Được Like
26
Mình áp dụng code dưới vẫn không được, có ai giúp mình không ?


#########################
# redirect www to no-www
#########################
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

#########################
# redirect port 80 to https (đã test):
# Always use https for secure connections
# Replace 'domain.com' with your domain name
# (as it appears on your SSL certificate)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://f123.vn/$1 [R=301,L]

chuyen f123.PNG
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mr. Tuấn

Mobile/Zalo: 0988 488 096

Telegram: bluekpro

Email: [email protected]

Nhà Tài Trợ

Mút Xốp Không Gian
pallet Thịnh Phát
Top Bottom