nginx重写url
我一直在玩Nginx配置,试图为我在Nginx上安装的Vanillaforums获取SEO友好的URL,但是,我非常困惑 基于这个URL,我提出了当前的配置nginx重写url,nginx,Nginx,我一直在玩Nginx配置,试图为我在Nginx上安装的Vanillaforums获取SEO友好的URL,但是,我非常困惑 基于这个URL,我提出了当前的配置 server { root /usr/share/nginx/html; index index.php index.php; server_name localhost; location / { try_files $uri/ $uri @rwtest; } loca
server {
root /usr/share/nginx/html;
index index.php index.php;
server_name localhost;
location / {
try_files $uri/ $uri @rwtest;
}
location @rwtest {
add_header X-Debug-Msg "uw0tm8";
rewrite ^(.*)$ index.php\?p=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
我可以直接进入页面(非SEO友好的URL),它可以正常工作,但是当我尝试使用“干净”的URL时,我只得到一个404错误。我也没有在标题中看到消息“uw0tm8”,这让我相信无论出于什么原因,rwtest都不会运行
提前谢谢 我会尝试用
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
以及摆脱@rw测试块
“基于前端控制器模式的软件包”下面有一个很好的资源,您需要在/conf/config.php
$Configuration['Garden']['RewriteUrls'] = true;
2) 只需更改nginx配置文件中的@vanilla
块
location @vanilla {
rewrite ^ /index.php?p=$uri&$args last;
}
我对这个问题的解决办法是
index index.php;
location / {
try_files $uri $uri/ /index.php?p=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
# Your PHP Setup
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
然后我添加了
$Configuration['Garden']['rewriteurl']=true根据AShish Tiwari的回答,将>编码到我的config.php。此解决方案不再适用于香草论坛2.3。如果有人知道如何使用nginx…香草2.3也有同样的问题@SamuelDeBacker,你有没有工作过?@AndrewAngell没有,我使用的论坛没有干净的URL。对我来说,工作很有魅力-谢谢,唯一可以帮助别人的是,这是除了vanilla at建议的所有nginx conf配置更改之外的,并取代了@vanilladefinition@skv太好了……)