如何在Web根目录中安装Wordpress的子目录中运行Joomla网站

时间:2017-07-19 18:24:15

标签: wordpress joomla3.0

我在example.com安装了Wordpress。

我确实在example.com/joomla安装了Joomla 3。

现在example.com/joomla出于某种原因加载了Wordpress 404。

即使example.com/joomla/index.php加载了Wordpress 404。

我可以看到/joomla文件夹中的Joomla文件完好无损,configuration.php包含正确的数据库详细信息。我可以在phpMyAdmin中看到数据库完整无缺。

当我在.htaccess文件夹中选中/joomla时,它被称为htaccess.txt。将其重命名为.htaccess并未解决问题。

如何确保Joomla 3网站从根域中安装Wordpress的子目录中再次正常运行?

提前致谢。

更新:这是网络根目录中的.htaccess/joomla-folder有一个默认的Joomla .htaccess

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} ^/?wp\-content/+debug\.log$
        RewriteRule .* - [F,L,NC]
</IfModule>
<IfModule !mod_rewrite.c>
    <Files "debug.log">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>
    </Files>
</IfModule>

# BEGIN litespeed noabort
<IfModule rewrite_module>
        RewriteEngine On
        RewriteRule .* - [E=noabort:1]
</IfModule>
# END litespeed noabort

# Redirect HTTP to HTTPS
<IfModule rewrite_module>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel
    <IfModule mod_mime.c>
        # DEFLATE by extension
        AddOutputFilter DEFLATE js css htm html xml
    </IfModule>
</IfModule>
<FilesMatch "\.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|TXT|XSD|XSL|XML)$">
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</FilesMatch>
<FilesMatch "\.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|BMP|CLASS|DOC|DOCX|EOT|EXE|ICO|WEBP|JSON|MDB|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|POT|PPS|PPT|PPTX|SVG|SVGZ|SWF|TIF|TIFF|TTF|TTC|_TTF|WAV|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW)$">
    <IfModule mod_headers.c>
         Header unset Last-Modified
    </IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*\/)?w3tc_rewrite_test([0-9]+)/?$ $1?w3tc_rewrite_test=1 [L]
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteRule .* - [E=W3TC_ENC:_gzip]
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
    RewriteRule .* - [E=W3TC_PREVIEW:_preview]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{REQUEST_URI} \/$
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core

# BEGIN WordPress
<IfModule rewrite_module>
RewriteEngine On
RewriteRule ^(dynamic-keyword-plugin-joomla)($|/) - [L]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress

# Wordfence WAF
<IfModule LiteSpeed>
php_value auto_prepend_file '/home/doigwebsite/public_html/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule mod_authz_core.c>
    Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
</IfModule>
</Files>

# END Wordfence WAF


# BEGIN MainWP

# END MainWP

#<IfModule mod_fcgid.c>
#MaxRequestLen 31457280
#</IfModule>

FileETag None
Header unset ETag 
Header unset Pragma

<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

Update2 :Joomla现在正在工作。我相信这可能是由于我自己对主持安排的困惑造成的 - 最近主持人转移了。

道歉。

3 个答案:

答案 0 :(得分:6)

将以下内容添加到WordPress安装根目录中的.htaccess文件中,紧跟在RewriteEngine On行之后:

RewriteRule ^(joomla)($|/) - [L]

例如:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
...

变为

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(joomla)($|/) - [L]
...

这会阻止WordPress仅在请求的路径以/joomla/开头时加载。

答案 1 :(得分:1)

如果您已在服务器上安装了nginx,则可以使用以下代码并在关闭服务器块之前将其添加到服务器块。

location = / {
    try_files $uri $uri/joomla-directory /joomla-directory/index.php?$args;
}

location /joomla-directory {
    index index.php;
    try_files $uri $uri/ /joomla-directory/index.php?$args;
}

希望这会有所帮助。

如果您使用的是共享主机,请将您的htaccess粘贴到WordPress根目录安装中,以及目录结构中。

答案 2 :(得分:1)

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(joomla)($|/) - [L]
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule> # END WordPress