繁体   English   中英

WordPress重定向到带有永久链接的子目录

[英]Wordpress redirect to a subdirectory with permalinks

我在domain.com/blog的子目录中有一个wordpress博客。 我想从主域访问它,而没有人看到它在子目录中。 我已经设法使用一些帮助从域到目录进行了透明的重定向,但是似乎无法使漂亮的永久链接正常工作。 这是我用于重定向的内容:

RewriteEngine on

# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Only apply to URLs that aren't already under /blog.
RewriteCond %{REQUEST_URI} !^/blog/

# Rewrite all those to insert /blog.
RewriteRule ^(.*)$ /blog/$1

# Redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ blog/ [L]

如果博客不在子目录中并且没有任何重定向,这就是我将用于永久链接的内容:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

就我尝试组合两个规则集而言,我要么得到一个无限循环,要么从wordpress中找不到。

那么如何将这两个规则集合并,以便可以通过重定向到子目录来访问博客并可以使用友好的url?

谢谢

永久链接只是您管理方面的设置,请转到设置并查找并更改网站网址,而不是wordpress网址!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM