WordPress Symfony同居 [英] WordPress Symfony Co-habitation

查看:66
本文介绍了WordPress Symfony同居的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个在Symfony上运行的网站,该网站是由比我本人更有能力的人开发的.但是,我在WordPress方面相当称职,并将在该站点上安装博客.

We have a site that runs on Symfony and that was developed by people much more competent that myself. I am however quite competent in WordPress and will be installing a blog on a the site.

当前,该站点的根目录运行在Symfony上,但是我希望WordPress能够接管而不必接触Symphony核心.本质上,我想将WordPress安装在www目录的子目录(例如www/wordpress/)中,并将htaccess指向该目录作为我的域的根目录.但是,我想仍然可以访问我的Symfony安装中的一项功能,将其称为myfeature.当我转到mydomain.com/myfeature/时,我希望htaccess指向由Symphony运行的mydomain.com/index.php/myfeature.

Currently, the root of the site runs on Symfony but I would like for WordPress to take over without having to touch the Symphony core. Essentially, I would like to install WordPress in a sub directory of the www directory, say www/wordpress/ and have htaccess point to that directory as the root of my domain. BUT, there is one function of my Symfony installation I would like to still have access to, lets call it myfeature. When I go to mydomain.com/myfeature/ I would like for htaccess to point to mydomain.com/index.php/myfeature which is run by Symphony.

这是我当前的.htaccess文件的样子.

Here's what my current .htaccess file looks like.

<IfModule mod_rewrite.c>
  RewriteEngine On

  # we skip all files with .something
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteCond %{REQUEST_URI} !\.php
  #RewriteCond %{REQUEST_URI} !\.php
  RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ /index.html [QSA]
  RewriteRule ^([^.]+)$ /$1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ /index.php [QSA,L]

  # hidden frontoffice controller
  RewriteRule ^index\.php/(.*)$ /index.php [QSA,L]
  # fo controllers
  RewriteRule ^frontend\.php/(.*)$ /frontend.php [QSA,L]
  RewriteRule ^frontend_dev\.php/(.*)$ /frontend_dev.php [QSA,L]
</IfModule>

谢谢

推荐答案

我使用以下方法将wordpress博客与我的symfony网站集成在一起.

I integrated a wordpress blog with my symfony site using the following.

//Added to the autoload.php
require('../vendor/wordpress/wp-blog-header.php');

我将博客安装到主Web文件夹中,并且.htaccess设置如下,

I installe the blog into the main web folder and the .htaccess was set as follows,

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/blog -------Add this condition to by pass the rewrite rules
RewriteRule ^(.*)$ app.php [QSA,L]

这允许所有其他路由正常访问,但博客路由保持不变,并直接传递给wordpress.为了从wordpress数据库中提取内容,我能够在symfony控制器中调用wordpress方法,并将其传递给我的树枝模板.

This allows all of the other routes to be accessed as normal but the blog routes are left untouched and passed directly to wordpress. To pull things from the wordpress database i was able to call the wordpress methods in my symfony controllers and pass it to my twig template.

$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
return array('posts'=>$posts);

我不确定这是否正是您要的内容,但这是我的wordpress博客和Symfony 2.0网站如何共存的方式.尽管我有一个wordpress模板和一个Symfony模板必须保持更新,但这确实是一个痛苦.我真的希望我能提出一个更好的解决方案,将它们整合到出色的工具中.

I am not sure if this is exactly what you are asking but it is how my wordpress blog and Symfony 2.0 site co-exist. It is a real pain though I have a wordpress template and a Symfony template that must be kept updated. I really wish I could come up with a better solution to bring these to great tools together.

这篇关于WordPress Symfony同居的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆