我有一个几页简单的网站,我只是希望所有其他请求被重定向到索引页,而不是显示404页。我的主机是plesk,我已经用
发布于 2018-05-31 21:38:19
这就是WordPress的工作原理-所有对不存在的文件或目录的请求都被重定向到index.php,将URL的第二部分作为index.php脚本的参数处理。
在Plesk for Linux上,你可以在Apache域> example.com > Apache 的附加部分添加所需的指令。在Windows上-到文档根目录中的web.config文件。
Apache mod_rewrite:
<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重写:
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php last;
}IIS URL重写:
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>https://stackoverflow.com/questions/50618755
复制相似问题