繁体   English   中英

htaccess重写到nginx配置无法正常工作

[英]htaccess rewrite to nginx config not working

我在使用nginx转换appache .htaccess文件时遇到问题。

.htaccess文件

<ifModule mod_rewrite.c>
    Allow from 127.0.0.1

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^index(|/)$ index.php
    RewriteRule ^logout(|/)$ logout.php
    RewriteRule ^keeping/([^/.]+)(|/)$ keeping.php?s=$1
</ifModule>

我的转换:

location / {
    if (!-e $request_filename){
        rewrite ^/index(|/)$ /index.php;
    }
}
location /logout {
    rewrite ^/logout(|/)$ /logout.php;
}
location /kyhsadminpanel {
    rewrite ^/keeping/([^/.]+)(|/)$ /keeping.php?s=$1;
}

不起作用。

它总是显示“404 not found”的网址,例如/kyhsadminpanel/keeping/index/kyhsadminpanel/keeping/news ...

您可能需要注意使用过: https//winginx.com/en/htaccess

我倾向于使用: https//timmehosting.de/htaccess-converter

这是他们的结果。

if (!-d $request_filename){
    set $rule_0 1$rule_0;
}
if (!-f $request_filename){
    set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
    rewrite ^/index(|/)$ /index.php ;
}
rewrite ^/logout(|/)$ /logout.php ;
rewrite ^/keeping/([^/.]+)(|/)$ /keeping.php?s=$1 ;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM