【问题标题】:permalinks is not working in xampp/localhost server on windows 7永久链接在 Windows 7 上的 xampp/localhost 服务器中不起作用
【发布时间】:2012-08-31 23:04:27
【问题描述】:

当我从 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

【问题讨论】:

  • 你使用什么网络服务器来运行 wordpress
  • :rash111 apache 服务器,因为它包含在 xampp 服务器中
  • 你看过apache错误日志了吗?
  • 你想删除 index.php 或其他任何东西

标签: wordpress .htaccess xampp permalinks


【解决方案1】:

如果您的项目位于
E:/xampp/htdocs/ozi-tech/
那么你需要指定从本地主机开始的路径。

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

【讨论】:

  • 为我工作只是在 index.php 行之前添加基本文件夹,.. 就像 Sergey 显示的那样:/ozi-tech/index.php [L]
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

    使用 .htaccess

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

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

    【讨论】:

      【解决方案4】:

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

      我通过在 httpd.conf 中添加:AllowOverride All outside 特定 &lt;Directory&gt; 标签解决了这个问题。

      所以,在 &lt;Directory /&gt; 主标签本身中,像这样:

      #
      # 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,但允许覆盖所有目录对我来说是一种快速解决方法。

      【讨论】:

        猜你喜欢
        • 2021-07-06
        • 2017-08-22
        • 2014-02-10
        • 2018-01-03
        • 2016-12-28
        • 2015-07-04
        • 2015-04-28
        • 2016-12-07
        • 1970-01-01
        相关资源
        最近更新 更多