[英]Move "handmade" htaccess to nginx config
主要問題是由https://winginx.com/htaccess轉換的代碼不起作用。 嘗試打開頁面時,它只有白皮書,沒有任何調試消息。
已經有了 nginx 配置:
server {
location / {
try_files $uri $uri/ /index.php?$args;
rewrite ^/course-track/* https://website.com/profile/? redirect;
rewrite ^/course-category/* https://websitw.com/profile/? redirect;
}
location /extra-online-testing/ {
rewrite ^(.*)$ https://website.com/tests/extra-online-testing/ redirect;
}
location = /my-courses/ {
rewrite ^(.*)$ https://website.com/profile/? redirect;
}
location = /courses/ {
rewrite ^(.*)$ https://website.com/profile/? redirect;
}
}
訪問:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/my-courses/$
RewriteRule ^.*$ https://website.com/profile/? [R=301,L]
RewriteCond %{REQUEST_URI} ^/course-track/*
RewriteRule ^.*$ https://website.com/profile/? [R=301,L]
RewriteCond %{REQUEST_URI} ^/courses/$
RewriteRule ^.*$ https://website.com/profile/? [R=301,L]
RewriteCond %{REQUEST_URI} ^/course-category/*
RewriteRule ^.*$ https://website.com/profile/? [R=301,L]
Redirect 301 /extra-online-testing/ https://website.com/tests/extra-online-testing/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我嘗試過其他轉換器,但結果相同。
試試這個代碼:),讓我知道這是否適合你:)
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.php index.html index.htm;
server_name your_domain.com;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location = /my-courses/ {
rewrite ^(.*)$ https://website.com/profile/? redirect;
}
location / {
rewrite ^/course-track/* https://website.com/profile/? redirect;
rewrite ^/course-category/* https://website.com/profile/? redirect;
}
location = /courses/ {
rewrite ^(.*)$ https://website.com/profile/? redirect;
}
location /extra-online-testing/ {
rewrite ^(.*)$ https://website.com/tests/extra-online-testing/ redirect;
}
location / {
rewrite ^/course-category/* https://website.com/profile/? redirect;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.