Ecommerce Shopify WordPress Discussion

access pages from wordpress installed in subfolder without the subfolder in url through htaccess [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 7 days ago. Improve this question I have two wordpress installations, one at example.com and another at example.com/landing so what I need to do is to show the page located at example.com/landing/page1 whenever somebody goes to example.com/page1 without any redirects using htaccess. I have tried various htaccess code pieces and one of them seems to work and it serves pages from the /landing subfolder but the pages of the existing website example.com/pages stops working here's the code: # RewriteCond %{REQUEST_URI} !^/landing/ [NC] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^(.*)$ landing/$1 [L] Is this even possible with htaccess?
... one of them seems to work and it serves pages from the /landing subfolder but the pages of the existing website example.com/pages stops working here's the code: # RewriteCond %{REQUEST_URI} !^/landing/ [NC] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^(.*)$ landing/$1 [L] Yes, as you've stated, this also rewrites all URLs from the WordPress installation in the root (and all assets) to the WP installation in the /landing subdirectory, so the existing website in the root essentially "breaks". However, if this is "working" to display page(s) from the /landing site (as if they are in the root) - as you suggest (so the WP installation in the /landing subdirectory must already be configured correctly, ie. WP_HOME and WP_SITEURL vars set) then you should just target the /page1 URL instead of everything. For example: # Rewrite "/page1" only to the WP installation in "/landing" RewriteRule ^page1$ landing/$0 [L] The $0 backreference contains the entire URL-path that is matched by the RewriteRule pattern (simply saves repeating page1 in this instance). This is an alternative to explicitly capturing the entire URL-path and using $1. eg. RewriteRule ^(page1)$ landing/$1 [L]. HOWEVER, this assumes you are linking to any relevant assets (CSS, JS, images, etc.) directly, so no additional URL-rewriting of these assets is necessary. If that's not the case and you also need to rewrite the relevant assets to the /landing subdirectory then you would need to incorporate these into the above rule (or create additional rules). For example: # Rewrite "/page1" and any relevant assets to the WP installation in "/landing" RewriteCond %{REQUEST_URI} =/page1 [OR] RewriteCond %{REQUEST_URI} =/wp-content/css/my-css.css [OR] RewriteCond %{REQUEST_URI} =/wp-content/js/my-js.js [OR] RewriteCond %{REQUEST_URI} =/wp-content/img/image1.jpg [OR] RewriteCond %{REQUEST_URI} =/wp-content/img/image2.jpg RewriteRule . landing%{REQUEST_URI} [L] Note that you will need to be selective in what you "rewrite", otherwise you will be back to the same problem of rewriting assets that the root WP installation is dependent on and the root WP site "breaks". Note that I used the = prefix-operator on the above conditions (RewriteCond directives). This makes the comparison an exact string match, not a regex, so no need to escape special characters or use regex anchors etc. Note also that the last RewriteCond directive does not (must not) have an OR flag. Otherwise, it will effectively be unconditional and rewrite everything again! OR, you could potentially rewrite any assets (CSS, JS and images) to /landing that are not found in the root (if that is how assets are referenced). This saves having to explicitly identify every asset that is used, at the expense of a filesystem check. For example: # Rewrite "/page1" and any assets that don't exist in the root RewriteCond %{REQUEST_URI} =/page1 [OR] RewriteCond %{REQUEST_URI} ^/wp-content/.+\.(js|css|jpg|webp)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . landing%{REQUEST_URI} [L]

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.