在WordPress中如何将根目录下的wp-content或wp-content/plugin目录链接重定向到主页?

4
如何在WordPress中将根目录/ wp-content重定向到主索引页面?我安装了重定向插件并定义它们的 http://www.heraldsolutions.in/wp-content/ http://www.heraldsolutions.in/ ,但它的重定向未起作用。我们已经维护了.htaccess应用规则,但它没有在主页上重定向。请帮助解决这个问题。
.htaccess文件代码:
<files wp-config.php>
order allow,deny
deny from all
</files>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^wp-content(/.*)?$ / [L,R,NC]
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^[a-z0-9]{1,4}[.](htm|pdf|jar) default.php [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
# Redirect /home http://heraldsolutions.in
Redirect /home /index.php
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
1个回答

3

在任何其他重写规则之前将此规则插入您的 WP .htaccess 中(仅在 RewriteBase 一行下方):

RewriteRule ^wp-content(/.*)?$ / [L,R,NC]

我已经更新了问题中的.htaccess代码,请在可能的情况下将其更正。@anubhava - gayatri
所以 http://www.heraldsolutions.in/wp-content/ 没有被重定向到 http://www.heraldsolutions.in/ - anubhava
@anubhva 我已经尝试过了,但现在无法加载主页,而且.../wp-content/重定向也不起作用。 - gayatri
我在我的WP安装中使用了完全相同的规则,它运行良好。 - anubhava
很高兴最终它对你起作用了。请标记答案为“已接受”,以帮助未来访问者解决问题。 - anubhava
显示剩余4条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接