2014-12-02 23 views
-2

我在windows 8.1 pro上使用winginx。我是新手使用它。我想在Windows上为nginx启用url重写,以便像这样的链接“http://mysite.dev/portfolio/latest/business-card-design/”正常工作。我想专门与wordpress和laravel合作。我发现如何将.htaccess文件转换为nginx,但我不知道把它们放在哪里。我希望你的专家们了解我的问题。对不起我的英语不好。请帮帮我。谢谢。如何在Windows PC上的nginx中启用url重写

+0

看看这里:[nginx http rewrite module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html),它可以帮助你做你正在寻找的东西。 – akmozo 2014-12-02 16:36:43

+0

你好,非常感谢你的回复。但我很抱歉,我无法通过链接解决我的问题。我对nginx真的很陌生。我不知道如何配置wordpress漂亮url的url重写。这是一个比xmapp快的服务器。但我非常难过,我无法使它适合我的wordpress主题开发与漂亮的网址。我在谷歌YouTube上搜索解决方案,但找不到合适的解决方案。请帮助我容易理解的细节。非常感谢你。 – 2014-12-02 20:00:17

+0

不要急躁,花点时间找到你要找的东西,然后做你想做的事。我不知道如何用nginx做wordpress,但我知道谷歌知道它;)所以看看[这里](http://wiki.nginx.org/WordPress)和[这里](http:///codex.wordpress.org/Nginx)。 – akmozo 2014-12-02 20:09:11

回答

0

我下载Winginx和安装Wordpress 4.0.1,这是我的配置:

server { 

    listen 127.0.0.1:80; 
    server_name example.com www.example.com; 

    root home/example.com/public_html; 

    index index.php index.html; 

    log_not_found off; 
    access_log logs/example.com-access.log; 

    charset utf-8; 

    location ~ /\. { deny all; } 
    location = /favicon.ico { } 
    location = /robots.txt { }  

    if (!-e $request_filename) { 
     rewrite ^(.+)$ /index.php?q=$1 last; 
    } 

    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; 
    } 

} 

利用这种配置,通过Winginx产生的,我的网站能正常工作,并且我已经加入了只有部分是URL重写部分:

if (!-e $request_filename) { 
    rewrite ^(.+)$ /index.php?q=$1 last; 
} 

当然,你必须从设置>永久链接选择你的固定链接设置,以获得你想要的URL。

+0

谢谢soooooooooooooooooooooooo我亲爱的。有用。我必须根据我的服务器名称和它的根来更改服务器名称,root的值。 Wooow。它的效果很好。我非常高兴。再次感谢您的大力帮助。 – 2014-12-08 20:25:38

+0

不客气。 – akmozo 2014-12-08 20:28:10