【问题标题】:how to correct rewrite nginx + apache urls如何更正重写 nginx + apache url
【发布时间】:2015-10-29 20:01:13
【问题描述】:

我有网站(前端 - nginx,后端 - (apache+php)),这是 nginx 配置文件

server {

listen *:80;
server_name website.plus www.website.plus;
access_log /var/log/nginx/access.log;
location / {
proxy_redirect          off;
proxy_pass http://127.0.0.1:81/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;

}

}

阿帕奇

<VirtualHost 127.0.0.1:81>
        ServerName website.plus
        ServerAlias www.website.plus
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/website

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

并且有这个网址

website.plus/tag.php?tag=cat
website.plus/search.php?search_content=cat
website.plus/view.php?image=LhUId4avpxVZK

请帮助我,我如何将网址更改(重写)为

website.plus/tag/cat
website.plus/search/cat
website.plus/view/LhUId4avpxVZK

谢谢

【问题讨论】:

    标签: apache mod-rewrite nginx url-rewriting rewrite


    【解决方案1】:

    试试这个(未经测试):

    rewrite ^tag.php?tag=(.*) tag/$1;
    rewrite ^search.php?search_content=(.*) search/$1;
    rewrite ^view.php?image=(.*) view/$1;
    

    我认为这很清楚(documentation of nginx's rewrite),但如果您有任何问题,请提出!

    【讨论】:

    • 哦,对不起,我不使用 apache...我对 apache 无能为力...对不起 :(
    猜你喜欢
    • 2011-10-13
    • 2012-03-26
    • 1970-01-01
    • 2014-05-29
    • 2013-04-03
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 2012-01-29
    相关资源
    最近更新 更多