WordPress Symfony Co-Housing

We have a site that runs on Symfony, and it was developed by people who are much more competent in this. However, I am quite competent in WordPress and will install the blog on the site.

The root of the site is currently running on Symfony, but I would like WordPress to take over without touching the core of Symphony. Essentially, I would like to install WordPress in a subdirectory of the www directory, say www/wordpress/ and point htaccess to this directory as the root of my domain. BUT, there is one feature of my Symfony installation that I would like to access, and call her myfeature . When I go to mydomain.com/myfeature/ , I would like htaccess to point to mydomain.com/index.php/myfeature , which is launched by Symphony.

This is 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> 

thanks

+4
source share
2 answers

I have included the wordpress blog with my symfony website using the following.

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

I put the blog in the main web folder, and .htaccess was installed 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] 

This allows access to all other routes as usual, but the blog routes remain untouched and are transferred directly to wordpress. To get things out of the wordpress database, I was able to call the wordpress methods in my symfony controllers and pass them to my branch template.

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

I'm not sure that this is exactly what you are asking for, but this is how my wordpress blog and Symfony 2.0 site coexist. This is a real pain, although I have a wordpress template and a Symfony template that needs to be updated. I really want me to be able to come up with a better solution to bring them to great tools.

+2
source

Here you go. I don't think anything below the wordpress controller line will ever be achieved, but I left it anyway

 <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). If yes, don't redirect RewriteRule ^$ /index.html [QSA] RewriteRule ^([^.]+)$ /$1.html [QSA] RewriteCond %{REQUEST_FILENAME} -f RewriteRule .* - [L] # if the 'myfeature' prefix is there, redirect to Symfony controller RewriteCond %{REQUEST_URI} ^/myfeature/ RewriteRule .* index.php [QSA,L] # otherwise, redirect to wordpress controller RewriteRule .* wordpress/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> 
+2
source

Source: https://habr.com/ru/post/1337130/


All Articles