V
V
Vladimir Kalaganov2018-03-10 19:45:19
WordPress
Vladimir Kalaganov, 2018-03-10 19:45:19

How to Subdomain a Wordpress Page Via mod_rewrite?

Please tell me how to make a subdomain for a Wordpress page.
For example:
Main site: computer-help5.rf
Subdomain: ufa.computer-help5.rf
Leads to the site page: computer-help5.rf/
ufa The hoster suggested that this can be done through mod_rewrite

Often hosting providers impose a limit on the number of unique sites, and often subdomains also fall under this limit. This restriction can be bypassed using .htaccess. For example, let's say we want to point the forum.yourdomain.net subdomain to the /forum directory. To do this, you need to direct the necessary subdomains to the folder with the main site and create a subdirectory, for example forum

RewriteCond %{HTTP_HOST} ^forum\.yourdomain\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/forum/ [NC]
RewriteRule (.*) /forum/$1 [L]

But I don't understand how to do it on wordpress
If I have such lines in .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

What should the resulting .htaccess file look like?
I did this for testing:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP_HOST} ^forum\.xn---5-6kctymdfgfbfek2a5jsbl0az\.xn--p1ai$ [NC]
RewriteCond %{REQUEST_URI} !^/forum/ [NC]
RewriteRule (.*) /forum/$1 [L]

Doesn't work and can't figure it out

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question