How to add an exception a route for routing - laravel - wordpress

I'm using laravel.my server is centOS7 and apache2.
This is my routing:
http://example.com/{en}/{county}
But now I want to launch a blog page with url:
http://example.com/{en}/blog
how to add an expected url?
my blog is a wordpress.

Laravel parses the routes in the order they have been added. Try this order when registering the rotues.
http://example.com/{en}/blog
http://example.com/{en}/{county}
It will first match the blog and then move for the patterns.
Now if you run php artisan route:list you will see both the routes have been registered.

by changing the order priority of routes will be changed...
try to use this order in the routes file web.php
.
.
http://example.com/{en}/blog
.
.
.
http://example.com/{en}/{county}
after that, you can redirect to your WordPress site URL:
Route::redirect('/{en}/blog', '/worpress-blog');

Related

Wordpress redirect to main host

I am looking for a WP php rule to always serve any webpage via the desired host without adding a redirect rule which is not an option in this case. see below.
We have our main site on one server and a WordPress installed on another server. We use cloudflare workers to serve the blogs content (blog.domain) via a subdirectory of the main server (domain.com/blog).
To avoid some issues on the admin side of WP we had to modify the wp-config.php to specify the correct host which would be the main domain/blog
$_SERVER['REQUEST_URI'] = '/blog' . $_SERVER['REQUEST_URI'];
$_SERVER['SCRIPT_NAME'] = '/blog' . $_SERVER['SCRIPT_NAME'];
$_SERVER['PHP_SELF'] = '/blog' . $_SERVER['PHP_SELF'];
$_SERVER['HTTP_HOST'] = 'www.domain.com';
source: https://core.trac.wordpress.org/ticket/36201#comment:17
What I noticed afterward is that (1) WP admin will always redirect the subdomain to the desired host, so if I go to the wp admin panel via the original subdomain it will redirect to the main-domain/blog/wp-admin.
( 2) Even when I hit a front end URL and I am logged in to the WP admin the same will happen, the host will be replaced.
(3) if I am not logged in to the admin panel but I am using a URL with a query parameter such as
https://sub.domain.com/?page_id=3
it will redirect to the desired host with the clean URL.
My question is how can I get WP to always redirect to the desired host? Using a simple redirect rule in PHP or apache/Nginx will result in an infinite loop (since the sub-directory is relying on the subdomain for the content)

Is any simple rest api simple endpoint for posts in Wordpress?

I am working with wordpress 4.9. I am trying to use new rest api. Is some api enpoints imlpemented by default? There is no /wp-json/wp/v2/posts nor /wp-json/wp/ nor /wp-json/ is accessible. The 404 is answer. What I need to check or enable? Is any ready stub snippet to make posts rest api endpoint?
Change the permalink setting. Maybe you can set permalink by post name.
Dashbord->Settings->Permalink
After saving changes https://****.**/wp-json/wp/v2/posts/ should work.
if it not works, maybe you need to enable mod_rewrite, on ubuntu:
a2enmod rewrite
sudo service apache2 restart
Actually rest url is differ or was recunfigured in wordpress I am working with.
The url in my case is https://{site}/rest_api/wp/v2
The actual url of the rest is possible to figure out by the next code:
echo get_rest_url();

Symfony FOSUserBundle https in mails

Symfony 3.4. I have a problem with forcing mailer use only https with URLs in mail such as activation/forgot password mail from FOSBundle, example:
message: |
Hello %username%!
To finish activating your account - please visit %confirmationUrl%
This link can only be used once to validate your account.
Regards,
the Team.
is there way to force mailer use https for %confirmationUrl% and others? Thanks!
Force the routes -that are used to generate full URL's- to https. See this page.
To do that you will have to add your own version of the fosuserbundle routing. You can find the routing files here.
Copy them to your src/AppBundle/Resources/config bundle directory and edit them to make them force https and change app/config/routing.yml to include your own files

WP subdomain multisite siteurl/home settings (no registration)

I have the following setup:
The primary domain is example.com. I'm not using this site for any other purpose than managing the other (sub)sites. All the core files are hosted at this address.
I'm using subdomains (not folders), so sub1.example.com, sub2.example.com, etc. to create new instances.
I'm disallowing registrations, so I'm defaulting to another site altogether in case nothing's there at the subdomain.
The wp-config.php contains the following relevant settings:
define('WP_ALLOW_MULTISITE',true);
define('MULTISITE',true);
define('SUBDOMAIN_INSTALL',true);
define('DOMAIN_CURRENT_SITE','www.example.com');
define('PATH_CURRENT_SITE','/');
define('SITE_ID_CURRENT_SITE',1);
define('BLOG_ID_CURRENT_SITE',1);
define('NOBLOGREDIRECT','https://www.default.com');
define('COOKIE_DOMAIN', false);
if (!defined('ABSPATH'))
define('ABSPATH',dirname(__FILE__) . '/');
define('WP_CONTENT_FOLDERNAME','custom-folder');
define('WP_CONTENT_DIR',ABSPATH . WP_CONTENT_FOLDERNAME);
define('WP_SITEURL','http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_CONTENT_URL',WP_SITEURL . WP_CONTENT_FOLDERNAME);
Now, my question is: assuming I've created a subdomain named "sub1.example.com"
for the new domain "landing-page1.com", what addresses should I ideally use for the Siteurl and Home fields in site-settings.php at the sub1.example.com instance?
Because currently I'm running into an issue where I've entered "http://www.landing-page1.com" for both fields, and "http://landing-page1.com" now consistently reverts to https://www.default.com, while "http://www.landing-page1.com" works as intended (showing the content for "http://sub1.example.com".
Ended up using 3rd party plugin: https://github.com/humanmade/Mercator to create a new alias. Seems superfluous, given WP's built-in domain mapping, but it does the trick.

Reverse proxy heroku app to wordpress blog

I've managed to setup a reverse proxy of my heroku app with the following in config.ru
require ::File.expand_path('../config/environment', __FILE__)
use Rack::ReverseProxy do
reverse_proxy /^\/blog(.*)$/, 'http://blog.domain.com$1', opts={:preserve_host => true}
end
run Appname::Application
This allows my heroku app to run at domain.com and have domain.com/blog appear as the URL while the wordpress site is being served blog.domain.com. Great so far.
The wordpress site gets served properly when going to domain.com/blog, however when I go to any deeper page like an individual post wordpress throws an error. I was using permalinks with the date and title in the URL of the form: domian.com/blog/2012/07/a-great-blog-post - Worpress now seems to not like this. When I switched the links back to the form domain.com/blog/?p=4 the page gets served successfully.
It seems like it doesn't handle and sort of trailing slashes after the inial domain.com/blog properly. What I find strange is domain.com/blog/wp-admin (and the entire WP admin app) works without any hiccups.
Can anyone see any glaring issues why the pages/post with multiple slashes '/' might be causing problems?
Thanks in advance!
Well I found a solution, for whatever reason in the WP settings for the permalink, it didn't like any of the default options except for the form where it can retrieve the post by id. (http://www.domain.com/blog/?p=123)
For SEO purposes I wanted the title of the post to be in the URL. So I entered in the custom structure field:
/index.php/%postname%/
It seems like it was requiring index.php for wordpress to handle the routing properly.

Resources