3

当我从 wordpress 管理员单击永久链接时,它会自动在根文件夹中创建 .htaccess 文件,然后 wordpress 站点停止使用浏览器错误服务器错误 500我在 httpd.conf 中进行了以下设置,并且我的 mod_rewrite 正在按照 php 工作。 ini 显示。

httpd.conf 设置

<Directory "E:/xampp/cgi-bin">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<Directory "E:/xampp/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options All

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

HTACCESS 文件代码

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /xampp/ozi-tech/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /xampp/ozi-tech/index.php [L]
</IfModule>
# END WordPress
4

4 回答 4

6

如果您的项目位于
E:/xampp/htdocs/ozi-tech/
上,那么您需要指定从 localhost 开始的路径。

E:/xampp/htdocs/  === localhost === /

您只需要更改.htaccess 中的RewriteBaseRewriteRule

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ozi-tech/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ozi-tech/index.php [L]
</IfModule>
# END WordPress
于 2015-09-22T18:37:59.730 回答
0

我确实很难解决这个问题,但我发现的主要问题是我的本地服务器不支持 htaccess URL 重写场景,所以我在 ftp 帐户上上传了相同的代码并在线获得了缓解。

我想知道我们是否可以允许在本地服务器中进行 URL 重写,尽管我在 xampp 服务器中取消了 URL 重写模块的注释,但仍然无法在本地环境中工作。

于 2014-05-03T05:43:04.643 回答
0

使用 .htaccess

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^([^\.]+)$ $1.php [NC,L]

上面的代码将去掉 .php 扩展名,从而让你说 index 而不是 index.php。是的,它适用于本地主机,几乎所有托管公司都包含它。

于 2014-09-05T07:56:26.553 回答
0

我在使用 XAMPP 时遇到了这个问题,并且我的项目位于与 XAMPP 的默认项目目录不同的目录中。

我通过添加:在httpd.conf特定标签AllowOverride All 之外解决了这个问题。 <Directory>

因此,在主<Directory />标签本身中,如下所示:

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride all
    Require all denied
</Directory>

如果您有更严格的安全需求,一定要弄清楚如何AllowOverride在特定目录中使用,但允许覆盖所有目录对我来说是一个快速修复。

于 2019-06-14T15:58:37.713 回答