【发布时间】:2017-07-15 02:07:28
【问题描述】:
我正在尝试将在 apache 服务器上生成的站点移动到 nginx 服务器。 我有当前的 .htaccess:
RewriteEngine on
RewriteRule ^(Personal)($|/) - [L]
RewriteRule ^mng/([-0-9a-zA-Z/%&]+)$ /index.php?aurl=$1 [L]
RewriteRule ^([-0-9a-zA-Z/%&]+)$ /index.php?url=$1 [L]
在线转换器已将这些规则转换为:
location /mng {
rewrite ^/mng/([-0-9a-zA-Z/%&]+)$ /index.php?aurl=$1 break;
}
location / {
rewrite ^/([-0-9a-zA-Z/%&]+)$ /index.php?url=$1 break;
}
我将它们添加到我的 nginx 配置中但不起作用,我错在哪里?
当我访问页面 domain.ex/mng/index 时,我可以下载该页面..
这是我完整的 nginx 配置文件:
server {
listen 80;
listen [::]:80;
root /var/www;
index index.php index.html;
server_name domain.ex;
location / {
rewrite ^/([-0-9a-zA-Z/%&]+)$ /index.php?url=$1 break;
}
location /mng {
rewrite ^/mng/([-0-9a-zA-Z/%&]+)$ /index.php?aurl=$1 break;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
【问题讨论】:
-
你能告诉我你的服务器配置吗?
-
我建议你查看这个页面:stackoverflow.com/questions/25591040/…
-
php7-fpm,nginx,但一切都很好我知道这一点,我可以访问我的资源,如 index.php?url=1 并且效果很好..
标签: apache .htaccess mod-rewrite nginx