我的 wordpress 告诉我将 htaccess 文件更新为:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我正在使用 nginx,我有这个,但是它不起作用:
location / {
root /home/mywebsite/public;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ~(.+)$ /index.php?q=$1 last;
}
}
答案1
尝试将其改为这样;
location / {
root /home/mywebsite/public;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
}
答案2
其运行完美。
并启用 PHP
将 PHP 脚本传递给监听 127.0.0.1:9000 的 FastCGI 服务器
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}