Situation
My client has a webshop in 2 languages:
- my-website.be (Dutch + French)
- my-website.nl (Dutch)
I have to remake the /blog for these 3 languages using Wordpress.
I have no access to the main website and server, so this has to be done with reverse proxy.
Ideally this will look like this:
- my-website.be/nl-be/blog/%postname%/
- my-website.be/fr-be/blog/%postname%/
- my-website.nl/blog/%postname%/
We use WPML(pro) for translation on the website
I have to proof this is possible
The problem
I'm trying to proof this is possible with wpml + reverse proxy on my local machine using MampPro for Windows. (As I do not have real/live servers/domains available to test this) And this is not working correctly whatever I try.
The local test setup
Made 2 local servers for reverse proxy:
my-site.localbe
my-site.localnl
Made 1 local server for the blog: my-site.test
Set the .htaccess files in the 2 proxy domains to reverse proxy this:
my-site.localbe
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^nl-be/blog/(.*)$ http://my-site.test/$1 [P]
RewriteRule ^fr-be/blog/(.*)$ http://my-site.test/$1 [P]
</IfModule>
my-site.localnl
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^blog/(.*)$ http://my-site.test/$1 [P]
</IfModule>
Setup 3 languages in WPML (nl-be, fr-be, nl-nl)
Set the Wordpress site url to the default http://my-site.test
==> with this setup both reverse proxy domain just show the default homepage and/or subpages. There's no way to access the other languages.
What we've tried
Changing Wordpress wp_home and wp_siteurl to:
/nl-be/blog (as nl-be is set as the default language in wpml)
Setting up wpml as "different domain for each language", but that places /nl-be/ hardcoded after each of those different domains.
(with wp_home and wp_siteurl set as my-site.test)
Fiddling with proxypass settings in .htaccess (probably wrong)
Changing the wpml language domains hardcoded in database
Overwriting the server_name variable in functions.php as follows:
$_SERVER['SERVER_NAME'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
Combinations and variations off all above.
Results
Mostly error 500
A broken .htaccess when saving permalinks
To much internal redirections
Links looking like my-site.testbe/nl-be/blog/nl-be/*
Styling and scripts loading from wrong domain
Combinations of all above
I would like to know
if this setup is even possible (local or on real linux servers)
if the mistake is in my reverse proxy / htaccess part
if the mistake is in configuring wordpress and wpml
any information that can help me solving this.
Thanks a lot,
a developer in distress
Related
I'm using multisite WordPress and qTranslateX plugin. My default website is in Bahasa and my second language is English. When I use custom link in mode language English like mydomain.com/multisite, it always added by "en" after mydomain.com, it will be mydomain.com/en/multisite. That link always return 404 because there is no page.
I want to use .htaccess to rewrite URL form mydomain.com/en/multisite to mydomain.com/multisite/en .
Thanks in advance
Unfortunately, you can't achieve that with mod_rewrite alone as far as I know.
Wordpress will look at the REQUEST_URI to figure out what to show, and that one won't be overwritten (and [E=REQUEST_URI:...] will make it $_SERVER["REDIRECT_REDIRECT_REQUEST_URI"]).
If mod_proxy is installed as well, you could do something like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en/([^/]+)(/?.*)$ /$1/en$2 [P,L]
It will proxy the request internally on the same host and server.
Requesting http://example.org/en/test will look to wordpress as if http://example.org/test/en was requested.
Give it a try. If mod_proxy isn't installed, it won't work (and render a 404 for the URL), but it won't break your site, so it's pretty safe to experiment with.
I stopped using domain.com as DocumentRoot for domain.nl as the WPML setup (WordPress Multilingual) with two domains each loading a single language from one DocumentRoot / CMS could not be done by Dreamhost admins and is no longer really condoned by Dreamhost on managed VPS as it requires customization of httpd.conf or working with custom vhosts. This they no longer allow on managed VPS and I understand.
I now work with one domain with the other language (nl) in a subdirectory of the .com domain. All still managed from one WP CMS using WPML
So I now I added a .htaccess to domain.nl with
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.nl$ [OR]
RewriteCond %{HTTP_HOST} ^domain.com.com$
RewriteRule (.*)$ https://domain.com/nl/$1 [R=301,L]
</IfModule>
I added this to stop customers from seeing 404s for pages like https://domain.nl/category/very-long-post-name/ where they should see https://domain.com/nl/category/very-long-post-name/
I do not see it redirecting yet. It still 404s at https://www.domain.nl/category/very-long-post-name/
Any ideas how I can fix this?
Well for all those who bump into similar issues working with mirroring of domains or using ServerAliasing and or changing of the DocumentRoot (web directory in Dreamhost) to use WordPress with WPML and two domains loading two languages.
Do not forget to do these changes or or undo them for HTTPS as well. Not only for HTTP. In the Dreamhost panel there are two locations under domains > manage domains. One for HTTP and one for HTTPS. Single last column is for HTTPS
For other hosters the places are probably different or you have to do it manually
I need to wordpress from 2 url, my main wp already run in subdomain wp.domain.com but I can't access from domain.com/wp, I try some change in database and .httaccess file, but I can't run it with 2 url
I need can access both of them :
wp.domain.com
domain.com/wp
WordPress doesn't really support this setup. All posts have saved their URL in the database, if you display the site on the secondary URL all links will still point to the primary URL.
Additionally, displaying the same content on different domains (what this is) is usually penalized by search engines, which is something you usually want to avoid.
You can achieve this by configuring the Apache with mod_proxy and mod_proxy_html to proxy all requests on one domain to the other, rewriting the URLs in the process.
The Apache config for this looks like this:
ProxyPass /wp/ http://wp.domain.com/
ProxyPassReverse /wp/ http://wp.domain.com/
# to rewrite the URLs in the HTML
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap http://wp.domain.com https://domain.com/wp
But I'd recommend to stick to a single URL and configure Apache to redirect all requests on the secondary URL to the primary.
You can do that with a single line in a .htaccess:
RewriteRule ^(.*)$ http://wp.domain.com/$1 [R=301,L]
I'm trying to install Wordpress in a subdomain on a shared hosting.
Me and my father have a domain together - artazov.cz. I have my own subdomain michal.artazov.cz. I want to go one level deeper and make a blog in the subdomain of the subdomain - blog.michal.artazov.cz. Now, it shouldn't matter, how many levels deep I go if I match it directly with regular expression in .htaccess. So that's what I did:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/?subdom/michal/subdom/blog/
RewriteCond %{HTTP_HOST} ^(www.)?blog\.michal\.artazov\.cz [NC]
RewriteRule ^(.*)$ http://artazov.cz/subdom/michal/subdom/blog/$1 [L,P]
There are 2 problems with this.
Wordpress by default is set up in a way, that in General settings, "Site Address (URL)" is set to http://artazov/subdom/michal/subdom/blog. Therefore every link on the website, including permalinks to articles, have this signature, instead of http://blog.michal.artazov.cz.
When I change that setting to http://blog.michal.artazov.cz, the website returns 404 Not Found and I have to go to database and change it back.
Is there some way to set it up so it works and runs in the desired subdomain, including all the links, generated by Wordpress itself? Thanks
Perhaps you have attempted likely to: Configurations in Wordpress-Admin >> Media Configurations Then try altering both:
I think you may should try changing permalinks:
http://codex.wordpress.org/Using_Permalinks
A have a custom website based on apache/php. I also have a wordpress blog and I would like it to be hosted in a different server.
I have tried to create a sub-domine like http://blog.mydomine.com but i would like to keep the old address (http://www.mydomine.com/corp/blog) for SEO purposes. I added the following configuration tu my .htaccess file.
RewriteCond %{REQUEST_URI} ^/corp/blog
RewriteRule ^(.*)$ http://blog.mydomine.com/$1 [L]
I would like to know if I can tell apache not to change the browser address after redirect the request. I know that I could do a 301 redirection but i would prefer to keep the old address.
Any ideas? Thanks in advance!! :)
Use the P flag
http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
RewriteRule ^(.*)$ http://blog.mydomine.com/$1 [P]
You could try a reverse proxy...
ProxyRequests Off
ProxyPreserveHost on
ProxyPass /corp/blog http://blog.mydomine.com/
ProxyPassReverse /corp/blog http://blog.mydomine.com/
ProxyPassReverseCookiePath /corp/blog /
This requires mod_proxy be installed and enabled.
Note that this will only work in the following contexts per the apache doc: server config, virtual host, directory - this means that putting it in a htaccess file won't work.
What you're wanting isn't really possible. It's not Apache that's displaying the address, it's the web browser, and there's no way (thankfully) to tell a web browser "go to site A, but tell the user it's site B."
You could fake this behavior using a frame page on your main site, but since you're wanting this for SEO I don't think that would help.