有关 htaccess 和两个 Wordpress 实例的帮助

发布于 2024-09-10 12:12:03 字数 1160 浏览 0 评论 0原文

我有一个旧的遗留应用程序,用 php 编写。它将被两个 WordPress 实例取代,一个是网站本身,另一个是博客(我必须将它们作为两个实例分开使用)。因此,我将为旧版本创建一个目录,为网站创建一个目录,为博客创建一个目录。

这是我的情况现在

假设我的应用程序网址是http://www.mywebsiteurltest.com/,我的目录结构如下:

..htdocs/old_site/
    files.php
    files.css
    blog/
        wordpress files

我不擅长 htaccess。因此,由于 http://www.mywebsiteurltest.com/ 指向 htdocs/old_site/,因此编写 http://www.mywebsiteurltest.com/blog / 转到 htdocs/old_site/blog/。所以我的解决方案是创建一个名为 blog 的目录而不是 .htaccess 解决方案来重定向。

我想要更专业的解决方案。我希望我的目录结构为:

..htdocs/
    old_site/
    site/
    blog/

因此,http://www.mywebsiteurltest.com/ 将转到 htdocs/site/http:// /www.mywebsiteurltest.com/blog/htdocs/blog/。我想知道如何在 htdocs/ 上创建 .htaccess 来完成此任务。最后我需要有 3 个 .htaccess:

htdocs/.htaccess 具有此配置(知道它将去哪个目录),由我在您的帮助下手动制作 再次htdocs/site/.htaccess,但使用站点 WordPress 实例配置,由 WordPress 自动创建 htdocs/blog/.htaccess,但带有博客 WordPress 实例配置,由 WordPress 自动制作

I have an old legacy application, written in php. It's going to be replaced by two Wordpress instances, one being the website itself and the other being a blog (I have to use them separated as two instances). So I'm going to have a dir for this old version, a dir for the site and a dir for the blog.

This is my situation now:

Suppose my app url is http://www.mywebsiteurltest.com/ and my dir structure is as follows:

..htdocs/old_site/
    files.php
    files.css
    blog/
        wordpress files

I'm terrible at htaccess. So, since http://www.mywebsiteurltest.com/ is pointing to htdocs/old_site/, writing http://www.mywebsiteurltest.com/blog/ goes to htdocs/old_site/blog/. So my solution was to create a dir named blog instead of a .htaccess solution to redirect.

I want a more professional solution. I would like my dir structure to be:

..htdocs/
    old_site/
    site/
    blog/

So, http://www.mywebsiteurltest.com/ would go to htdocs/site/, and http://www.mywebsiteurltest.com/blog/ to htdocs/blog/. I would like to know how to create an .htaccess on htdocs/ to accomplish this. In the end I need to have 3 .htaccess:

htdocs/.htaccess with this configuration (knowing to which dir it's going to go), manually made by me with your help
htdocs/site/.htaccess again, but with site wordpress instance configuration, made automatically by wordpress
htdocs/blog/.htaccess, but with blog wordpress instance configuration, made automatically by wordpress

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

已下线请稍等 2024-09-17 12:12:03

所以你想要这个,对吧?

http://www.example.com/          --> /htdocs/site/
http://www.example.com/blog/     --> /htdocs/blog/
http://www.example.com/old_site/ --> /htdocs/old_site/

如果是这样,你可以尝试这个...

/htdocs/.htaccess/htdocs/site/.htaccess(WordPress

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_URI} !^/old_site/
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^.*$ /site/$0

应该做什么+一点额外的):

RewriteEngine On
RewriteBase /

# Prevent people from going to /site/ directly
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/site [NC]
RewriteRule ^.*$ http://www.example.com/$0 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

>/htdocs/blog/.htaccess(WordPress 应该做什么):

RewriteEngine On
RewriteBase /blog/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

So you want this, right?

http://www.example.com/          --> /htdocs/site/
http://www.example.com/blog/     --> /htdocs/blog/
http://www.example.com/old_site/ --> /htdocs/old_site/

If so, you can try this...

/htdocs/.htaccess:

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_URI} !^/old_site/
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^.*$ /site/$0

/htdocs/site/.htaccess (What WordPress should do + a little extra):

RewriteEngine On
RewriteBase /

# Prevent people from going to /site/ directly
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/site [NC]
RewriteRule ^.*$ http://www.example.com/$0 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

/htdocs/blog/.htaccess (What WordPress should do):

RewriteEngine On
RewriteBase /blog/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文