I have a wordpress site but I want to have subdomains that will redirect to dir

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{HTTP_HOST} ^sub\.domain\.com$
RewriteCond %{REQUEST_URI} !^sub-folder/sub/index.php
RewriteRule ^(.*)$ sub-folder/sub/index.php?c=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !sub-folder/sub/index.php
RewriteRule . /index.php [L]


This is one of many versions I've tried. The intention is that if a user goes to

https://domain.com or https://domain.com/blog/this-is-an-article etc it will display correctly in wordpress but if they go to

https://sub.domain.com/1234 that they will end up seeing the content of https://domain.com/sub-folder/sub/index.php?c=$1 where obviously 1234 == $1

  • To clarify, the URL you are wanting to rewrite to is entirely outside of WordPress? And the subdomain points to the same place as the main domain? – MrWhite Jul 28 '19 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.