ウェブサイトをデフォルトの /year/month/day/post_title パーマリンクから単純な /post_title/ リンクに変更しようとしていますが、変更すると古いリンクがすべて壊れてしまいます。.htaccess を使用して Apache でそれを行う方法に関するサイトを読みましたが、mod_rewrite の代わりに nginx の場所で機能させる方法を理解するのに助けが必要です。
これは、Apache http://www.rickbeckman.org/how-to-update-your-wordpress-permalinks-without-causing-link-rot/
でそれを行う方法を詳しく説明しているサイトです。
そして、この htaccess を nginx に使用してみましたコンバータhttp://winginx.com/htaccessただし、正規表現が問題を引き起こしている可能性があり、nginx の起動時にこのエラーが発生します
[emerg]: unknown directive "4}/[0-9]" in /usr/local/nginx/sites-enabled/website.com:19
そして、これは私の構成ファイルです
server {
listen 80;
server_name website.com;
rewrite ^/(.*) http://www.website.com/$1 permanent;
}
server {
listen 80;
server_name www.website.com;
error_log /home/user/public_html/website.com/log/error.log;
client_max_body_size 10M;
client_body_buffer_size 128k;
location / {
root /home/user/public_html/website.com/public/;
index index.php index.html;
try_files $uri $uri/ /index.php;
}
location ~ ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9\-/]+) {
rewrite ^(.*)$ http://website.com/$1 permanent;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$
{
fastcgi_read_timeout 120;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/user/public_html/website.com/public/$fastcgi_script_name;
}
}
誰でもそれを修正する方法を知っていますか?ありがとう。