【问题标题】:Joomla home page redirect with nginx使用 Nginx 重定向 Joomla 主页
【发布时间】:2016-04-05 17:10:01
【问题描述】:

我正在使用 Joomla 多站点尝试重定向站点的第一页:

类似的东西:

subdomain.mysite.io/  ->  subdomain.mysite.io/yoga

我尝试使用该解决方案:How to redirect single url in nginx?

location / {
   rewrite ^/.* http://$subdomain.mysite.io/yoga permanent;
}

但我与配置文件发生冲突...这是我的子域的 nginx 文件...

有人可以帮我解决这个问题吗?我正在使用友好的重写规则!

server {

listen 80;
server_name subdomain.mystie.io www.subdomain.mysite.io;
server_name_in_redirect off;

root /home/joomla/mysite;
index index.php index.html index.htm;


# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
        return 403;
        error_page 403 /403_error.html;
}

# Support Clean (aka Search Engine Friendly) URLs
location / {
    try_files $uri $uri/ /index.php?$args;

}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
     root /home/workspaces/php/joomla/portal;
}


# caching of files 
location ~* \.(ico|pdf|flv)$ {
        expires 1y;
}

location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt|woff)$ {
        expires 14d;
}



location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
}

【问题讨论】:

    标签: php .htaccess redirect nginx joomla


    【解决方案1】:

    要选择单个 URI,请使用 location = 变体。要使重定向永久化,请使用return 301。试试:

    location = / { return 301 $scheme://$host/yoga/; }
    

    详情请参阅this documentthis document

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-17
      • 2014-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多