Wordpress. Redirect from pages to subdomains
There is a plugin for WordPress https://wordpress.org/plugins/page-as-subdomain-lite/, which creates subdomains from page posts. For example, we added a page with a test slug in WordPress that looks like site.com/test, the task when navigating to it is to redirect to the subdomain test.site.com. We need code + entries for htaccess. The A record *has been added in the cloud. ChatGPT does not understand or cannot comprehend the task.
add_action('template_redirect', 'redirect_to_subdomain');
function redirect_to_subdomain() {
if (is_page()) {
global $post;
$slug = $post->post_name;
// Define the main domain of the site
$site_url = home_url();
$parsed_url = wp_parse_url($site_url);
$base_domain = $parsed_url['host'];
// Check if the page is not on the subdomain
if (strpos($_server['HTTP_HOST'], $slug . '.') === false) {
// Redirect to the subdomain
wp_redirect('https://' . $slug . '.' . $base_domain . $_server['request_URI'], 301);
exit;
}
}
}
-
934 16 0 Hello. Write to me, I will do everything quickly and efficiently...........
-
4926 88 0 Good day, Liliya
I will complete it within 1-2 hours
Message me in private, I will start immediately
-
12437 600 0 Hello, I can handle your task and write the necessary redirects according to your needs. Message me privately - we will discuss..................
Current freelance projects in the category PHP
Make sure that order emails from the store do not go to spam.Currently, there is a store on OpenCart, and order emails are landing in spam. We need to ensure they go to Inbox (ukr.net gmail) and check it. The hosting provider wrote: Poor email delivery may be related to a low sender reputation - IP or domain. In this case, we can advise… PHP, Web Programming ∙ 8 hours 51 minutes back ∙ 44 proposals |
Transfer the fully ready adaptive HTML5 structure to WordPress.
267 USD
I am looking for an experienced WordPress developer who can convert our meticulously prepared static HTML5/CSS3 code into a high-performance custom WordPress theme. The frontend is almost ready (about 99%): semantic markup, metadata, and multilingual structure (hreflang) are… Content Management Systems, PHP ∙ 3 days 10 hours back ∙ 68 proposals |
GoPos IntegrationHello, has anyone done an integration of GoPos with a custom website for a restaurant in Poland? I need help, their documentation is very sparse, there is only swagger and it lacks descriptions. https://app.gopos.io/doc/swagger-ui/index.html The essence is this: we used their… PHP, Web Programming ∙ 4 days 2 hours back ∙ 25 proposals |
Write meta data for ALT using AIA website on Laravel, the site has many images for which it is necessary to automatically generate correct semantic and relevant ALT descriptions for the images, with the possibility of verification. AI & Machine Learning, PHP ∙ 4 days 23 hours back ∙ 35 proposals |
A developer is needed to complete and integrate a project for automatic data collection and processing.
16 USD
The main part of the parser has already been implemented. The parser works in a Windows environment through Microsoft Edge: the site has anti-bot protection, so data collection is performed not through direct HTTP requests, but through a live browser session. The scripts control… PHP, Web Programming ∙ 5 days 5 hours back ∙ 26 proposals |