gpt4 book ai didi

.htaccess - URL 重写在 Nginx 中不起作用

转载 作者:行者123 更新时间:2023-12-04 16:24:20 26 4
gpt4 key购买 nike

URL 重写在 Nginx 中不起作用,操作系统是 Ubuntu 12.4 Lts

当打开 http://mvc.loc 它正在工作
但是当我尝试打开 http://mvc.loc/login 时不工作

404 未找到

nginx/1.1.19

.htaccess

<IfModule !mod_rewrite.c>
ErrorDocument 500 "mod_rewrite must be enabled"
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?u=$1

mvc.loc 的虚拟主机
server {
listen 80;
server_name mvc.loc;
access_log /var/log/nginx/mvc.loc.access.log;
error_log /var/log/nginx/mvc.loc.error.log;
root /usr/share/nginx/www/mvc;

index index.php;


# use fastcgi for all php files
# Are you sure you have this set up?
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to apache .htaccess files
location ~ /\.ht {
deny all;
}

}

最佳答案

location / {    
rewrite ^(.*)$ /index.php?u=$1 last;
}

关于.htaccess - URL 重写在 Nginx 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19039983/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com