无法使用 Python/Django + React-Admin 设置在 cPanel 上访问 WordPress

问题描述 投票:0回答:1

我有一个使用 cPanel 的共享托管设置,我在其中部署了一个 Python 应用程序,以 Django 作为后端,以 React-admin 作为前端。此外,我已将 WordPress 安装在子目录中(例如 karmodir.ir/wp/)。但是,每当我尝试访问 WordPress 子目录时,我总是会被重定向到 React-admin 前端,并且 WordPress 网站显示为空白页面。

我尝试了各种配置,包括修改 .htaccess 和 React-admin 中的路由。 React-admin 应用程序运行良好,但我无法绕过它来查看子目录中的 WordPress 站点。

export const App = () => (
  <CacheProvider value={cacheRtl}>
    <BrowserRouter>
      <Routes>
        {/* redirection for /wp/ */}
        <Route path="/wp/*" element={<Navigate to="/wp/" replace />} />
        {/* Main routing for SiteAdmin */}
        <Route path="/*" element={<SiteAdmin />} />
      </Routes>
    </BrowserRouter>
  </CacheProvider>
);

这是.htaccess:

# Redirect /wp/ to the correct WordPress path
RewriteEngine On

# Ensure the rule only applies to /wp/ requests
RewriteCond %{REQUEST_URI} ^/wp/
RewriteRule ^wp/(.*)$ http://karmodir.ir/wp/$1 [L,R=301]

# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/karmodir/jkar/jkar"
PassengerBaseURI "/"
PassengerPython "/home/karmodir/virtualenv/jkar/jkar/3.10/bin/python"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END

# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END
wordpress .htaccess
1个回答
0
投票

以下代码适用于

.htaccess

RewriteEngine On

# If the request is for the wp subdirectory, send it to WordPress
RewriteCond %{REQUEST_URI} ^/wp/
RewriteRule ^wp/(.*)$ /wp/$1 [L]

# Ensure any file or directory under wp/ is served by WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wp/(.*)$ /wp/index.php [QSA,L]
© www.soinside.com 2019 - 2024. All rights reserved.