将mod_rewrite Apache转换为Nginx?
我是网络编程新手。我想将Apache切换到Nginx web服务器,但Nginx模式重写仍然存在问题 我在将mod_rewrite Apache转换为Nginx?,apache,mod-rewrite,nginx,Apache,Mod Rewrite,Nginx,我是网络编程新手。我想将Apache切换到Nginx web服务器,但Nginx模式重写仍然存在问题 我在/home/user/public\u html/read/上的网站位置和我以前在/home/user/public\u html/read/.htaccess上的.htaccess文件如下: Options +FollowSymlinks RewriteEngine on RewriteRule ^mangas/([^/]+)/([^/]+)/$ - [F,L] RewriteRul
/home/user/public\u html/read/
上的网站位置和我以前在/home/user/public\u html/read/.htaccess上的.htaccess
文件如下:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^mangas/([^/]+)/([^/]+)/$ - [F,L]
RewriteRule ^mangas/([^/]+)/$ - [F,L]
RewriteRule ^mangas(/?)$ - [F,L]
RewriteRule ^([^/.]+)/([^/.]+)/([0-9]+)(/?)$ index.php?manga=$1&chapter=$2&page=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)(/?)$ index.php?manga=$1&chapter=$2 [L]
RewriteRule ^([^/.]+)(/?)$ index.php?manga=$1 [L]
如何将此mod_重写转换为nginx?(我很高兴,因为我的英语拼写不完美)在你的服务器{}
上试试这些:
location ~ ^/mangas/([^/]+)/([^/]+)/$ {
return 403;
}
location ~ ^/mangas/([^/]+)/$ {
return 403;
}
location ~ ^/mangas(/?)$ {
return 403;
}
location / {
rewrite ^/([^/.]+)/([^/.]+)/([0-9]+)(/?)$ /index.php?manga=$1&chapter=$2&page=$3 break;
rewrite ^/([^/.]+)/([^/.]+)(/?)$ /index.php?manga=$1&chapter=$2 break;
rewrite ^/([^/.]+)(/?)$ /index.php?manga=$1 break;
}
在您的服务器{}
中尝试以下操作:
location ~ ^/mangas/([^/]+)/([^/]+)/$ {
return 403;
}
location ~ ^/mangas/([^/]+)/$ {
return 403;
}
location ~ ^/mangas(/?)$ {
return 403;
}
location / {
rewrite ^/([^/.]+)/([^/.]+)/([0-9]+)(/?)$ /index.php?manga=$1&chapter=$2&page=$3 break;
rewrite ^/([^/.]+)/([^/.]+)(/?)$ /index.php?manga=$1&chapter=$2 break;
rewrite ^/([^/.]+)(/?)$ /index.php?manga=$1 break;
}
O certo seria:
location ~ ^/mangas/([^/]+)/([^/]+)/$ {
return 403;
}
location ~ ^/mangas/([^/]+)/$ {
return 403;
}
location ~ ^/mangas(/?)$ {
return 403;
}
location / {
rewrite ^/([^/.]+)/([^/.]+)/([0-9]+)(/?)$ /index.php?manga=$1&chapter=$2&page=$3 last;
rewrite ^/([^/.]+)/([^/.]+)(/?)$ /index.php?manga=$1&chapter=$2 last;
rewrite ^/([^/.]+)(/?)$ /index.php?manga=$1 last;
}
Não sei porquê,mas,最后一项职能的变更。o certo seria:
location ~ ^/mangas/([^/]+)/([^/]+)/$ {
return 403;
}
location ~ ^/mangas/([^/]+)/$ {
return 403;
}
location ~ ^/mangas(/?)$ {
return 403;
}
location / {
rewrite ^/([^/.]+)/([^/.]+)/([0-9]+)(/?)$ /index.php?manga=$1&chapter=$2&page=$3 last;
rewrite ^/([^/.]+)/([^/.]+)(/?)$ /index.php?manga=$1&chapter=$2 last;
rewrite ^/([^/.]+)(/?)$ /index.php?manga=$1 last;
}
Não sei porquê,mas,alterando de break para last Functiona.仍然不起作用:(当我尝试访问我的网站时,看起来像是下载了一些“应用程序流”。有人帮我提供其他参考吗?@FikriOnline你使用什么应用程序服务器来进行PHP?PHP fpm?你是如何配置nginx与之交互的?仍然不起作用:(当我尝试访问我的网站时,看起来像是下载了一些“应用程序流”。有人能帮我提供其他参考吗?@FikriOnline你使用什么应用程序服务器来进行PHP?PHP fpm?你是如何配置nginx与之交互的?你介意翻译成英语吗(如果可能的话).没有恶意或其他什么-但这个网站是一个英语网站,覆盖范围最广。坚持通过谷歌翻译就可以了。你介意翻译成英语吗(如果可能的话).没有恶意或任何东西-但这个网站是一个英语网站,覆盖范围最广。坚持通过谷歌翻译可以作为一个开端。