【问题标题】:Can't access sub directory on server无法访问服务器上的子目录
【发布时间】:2014-12-18 20:37:50
【问题描述】:

我有一个在其根目录上安装了 wordpress 的服务器(它已经上线了)。现在我在根目录下创建了一个新目录,并想在上面安装另一个 wordpress。当我尝试访问该子目录时,它的显示页面未找到错误。

My .htaccess file is as follows

# BEGIN s2Member GZIP exclusions

<IfModule rewrite_module>

 RewriteEngine On

RewriteBase /

RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]

RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1

RewriteRule .* - [E=no-gzip:1]

</IfModule>

# END s2Member GZIP exclusions

# 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

尝试了以下方法,但没有成功

ErrorDocument 401 default
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/english/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

子目录名是英文。

谁能帮忙!!! 提前致谢

【问题讨论】:

  • 您的子目录中有 htaccess 文件吗?
  • @JonLin 不,我在那个子目录上没有 .htaccess 文件
  • 如果你删除上面提到的新块并在英文文件夹中创建一个测试页面文件,这样可以吗?
  • @LucasF 创建了一个 index.html 和 index.php 页面,我可以访问 html 页面但无法访问 php 页面

标签: php wordpress apache .htaccess


【解决方案1】:

如果您在 htdocs 中有此规则,则应该可以:

Options +FollowSymLinks

<IfModule rewrite_module>
    RewriteEngine On
    RewriteBase /
    # BEGIN s2Member GZIP exclusions
    RewriteCond %{QUERY_STRING} (^|\?|&)s2member_file_download\=.+ [OR]
    RewriteCond %{QUERY_STRING} (^|\?|&)no-gzip\=1
    RewriteRule .* - [E=no-gzip:1]
    # END s2Member GZIP exclusions

    # BEGIN WordPress
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
</IfModule>

这在英文子文件夹中:

ErrorDocument 401 default
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /english/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

【讨论】:

  • 谢谢,上面的代码试过了,还是不行,还是显示page not found错误。
  • 嗯......在我的环境中它正在工作。还有其他规则吗?也许在 httpd.conf 中?
  • 能否请您在 /english 中创建另一个 php 脚本并尝试访问它
  • 它正在工作...,我创建了另一个文件夹并将您的代码放入其中。我在 /english 文件夹中有 wordpress 文件可能是因为它不起作用。
  • 也许还有浏览器缓存...那你会接受我的回答吗?
猜你喜欢
  • 2014-07-26
  • 2012-01-18
  • 2014-09-25
  • 1970-01-01
  • 1970-01-01
  • 2015-07-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多