0

I have installed wordpress in the subdirectory "sub". I need the same content been accessed from the root and also from the subdirectory "sub". So I have created the following rewriting rules and placed them in a .htaccess file of the root

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteRule ^$ sub/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ sub/$1


</IfModule>

Everything works as expected. If I visit mydomain.com/sub/post1 or mydomain.com/post1 I can see the same content but when I am at the root if I click a link for example the link for the next post the link will be mydomain/sub/nextpost. How could get rid of the name of the subdomain in the link when I am viewing the site from the root? What rewrite rule should I use for that?

  • "What rewrite rule should I use for that?" - It's not a "rewrite rule" that you need. You need to tell WordPress to construct the permalinks differently depending on the URL-path by which the site is being accessed. – MrWhite Jul 9 '18 at 23:53
  • Thank you for your advice! But how could I do that, could you point me to the right direction? I cannot find a way to tell wordpress to change the permalink conditionally depending on the url-path. Could you please give me some more information? – Ioannis Jul 11 '18 at 20:45

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.