sho*_*000 3 centos .htaccess wordpress apache-2.2
在我的 apache 配置中,我有以下设置
<Directory "/opt/website/new-website-old/httpdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location /server-status>
#AllowOverride None
SetHandler server-status
Order deny,allow
Deny from all
Allow from all
</Location>
Run Code Online (Sandbox Code Playgroud)
使用此服务器状态可以工作,但是如果我将allowoverride选项更改为所有选项,则不会。如果allowoverride选项设置为All,我如何让服务器状态正常工作
我已经遵循了这个,但仍然没有运气wordpress 服务器状态
在我当前的 ht 访问文件中,我有
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www.asb.com.au$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/about/the-group/domain-asb$1 [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Run Code Online (Sandbox Code Playgroud)
首先,我对您在 location 块中使用以下内容感到困惑,我觉得您可能想拒绝所有人,但可能想从您自己的 IP 中允许,但我离题了。
Deny from all
Allow from all
Run Code Online (Sandbox Code Playgroud)
您从发布的指南中错过的最重要的事情是以下行:
RewriteCond %{REQUEST_URI} !=/server-status
Run Code Online (Sandbox Code Playgroud)
这将使 .htaccess 文件看起来更像这样:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Run Code Online (Sandbox Code Playgroud)
最重要的是,您的 .htaccess 中似乎有两个单独的重写块,它们几乎相同,我会将它们合并为一个,以使 .htaccess 的最终内容成为(并且没有其他内容):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www.asb.com.au$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/about/the-group/domain-asb$1 [R=301,L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
为您提供更多信息,将 AllowOverride 设置为 none 会使 apache 完全忽略 .htaccess 文件,因此当它设置为 all 时,显然会告诉您 .htaccess 中的某些内容会覆盖 /server-status 的功能由服务器状态处理程序处理。在您的 .htaccess 文件中,违规行基本上是:
RewriteRule . /index.php [L]
Run Code Online (Sandbox Code Playgroud)
这告诉 apache 重写所有内容并将其发送到 index.php,这是因为 wordpress 通过 index.php 处理所有内容并允许 SEO url 等。
我们添加的行:
RewriteCond %{REQUEST_URI} !=/server-status
Run Code Online (Sandbox Code Playgroud)
告诉 apache 执行我们上面所说的(根据 RewriteRule 将所有内容重写到 index.php),除非 URI 是 /server-status - 因为它将不再被重写并发送到 wordpress index.php,处理程序应该能够表现得像预期的那样。
另外两个条件
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Run Code Online (Sandbox Code Playgroud)
据您所知,如果请求是实际文件或实际文件夹,请告诉 apache 不要重写 url。
您可以在官方文档中阅读有关 Mod_Rewrite 的更多信息。
| 归档时间: |
|
| 查看次数: |
8602 次 |
| 最近记录: |