2014-12-02 70 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