Looking for some help with using Wordpress behind a reverse proxy. Got two issues.
The setup is like this.
We host the Wordpress site at: www.myblog.com
The Wordpress version is 5.6.4.
The client reverse proxies the site with IIS at: www.ourdomain.com/blog/
Trailing Slashes
Wordpress will redirect requests from it's root. So if a page request is missing a trailing slash, it will 404. So for example:
Request: https://www.ourdomain.com/blog/myarticle
Redirects to: https://www.ourdomain.com/myarticle which is a 404. It should stay at: https://www.ourdomain.com/blog/myarticle.
It currently only works with a trailing slash.
Indexing for Search Engines
What is the best way to prevent search engines from indexing the site at: www.myblog.com but still allow indexing at:
www.ourdomain.com/blog/
Related
I have moved my phpBB board from dommain.com to domain.com/forum.
I have launched a Wordpress website on domain.com.
As a consequence, all links to topics on my board end up on a 404 page of my Wordpress website on domain.com
I would like to redirect links to topics on my board.
For example:
Redirect: example.com/viewtopic.php?f=17&t=35
To: example.com/forum/viewtopic.php?f=17&t=35
So only /forum should be added.
Is changing the .htaccess file of my WordPress website the best way to do this? And if so, what would be the correct code?
Of are there better ways (faster/better for SEO) that I don't know of.
Is changing the htaccess file of my Wordpress website the best way to do this?
Implementing this in the root .htaccess file is a reasonable way to do this, unless you have access to the main server config. Alternatively, you could perform this redirect in PHP (in WordPress), but that puts the burden on your WordPress site.
For example, at the top of your root .htaccess file, before the existing WordPress directives (ie. before # BEGIN WordPress) try the following:
# Redirect old forum topics to "/forum" subdirectory
RewriteRule ^viewtopic\.php$ /forum/$0 [R=301,L]
Any query string is passed through by default. So, a request for /viewtopic.php?<something> is redirected to /forum/viewtopic.php?<something>.
The $0 backreference contains the URL-path matched by the entire RewriteRule pattern. ie. "viewtopic.php" (this simply saves repetition).
NB: You should test first with a 302 (temporary) redirect to avoid potential caching issues.
I'm using nginx and I found some 404 errors for WordPress blog searches. I need to make a rewrite in nginx but I need help to do.
Eg:
404 URL
http://example.com/blog/?s=searchterm
Should be redirected to
http://example.com/?s=searchterm
I have a server that host a variety of asp.net sites on a IIS7 server.
A few of those sites have wordpress blogs in a folder called blog (which is obviously written in PHP). Due to security issues, we need to move those wordpress blogs to a linux server.
So instead of http://www.domainname.com/blog we now have http://blog.domainname.com/ which has the blog url.
The only problem is, due to SEO reasons, we need the blog to be on the same domain as the main site (which is written in ASP.NET).
My question is, is there a way to do a url rewrite so that if someone types in a wordpress link, similar to this:
http://www.domainname.com/blog/index.php/archives/category/mycategory
Can I use a web config URL rewrite to have the above typed in URL actually point to
http://blog.domainname.com/index.php/archives/category/banking
I can't do any sort of redirect. It has to be a rewrite, I've tried righting one myself but have been unable to. The subdomain is the part of the rewrite I can't get past.
Has anyone tried to do this before?
Is there some better way I go about this if not.
Keep in mind the blog and the asp.net site cannot be on the same server due to security reasons, but they must keep the same domain name.
You can't just do a rewrite as the URL you want to rewrite to is on another domain / website. Rewrites only work on the same website.
You have to setup IIS as a reverse proxy server with the ARR module. In combination with the URL rewrite module you will be able to invisibly forward all requests for http://www.domainname.com/blog/* to http://blog.domainname.com/*.
Also note that you will have to setup outbound rewriting in order to change back the URL's that are generated by Wordpress (from http://blog.domainname.com/* back to http://www.domainname.com/blog/*).
See for an example this tutorial: Reverse Proxy with URL Rewrite v2 and Application Request Routing.
For some reason my Wordpress install now requires a trailing slash after the page name.
For instance http://somedomain.com/page-name (404's)
Yet http://somedomain.com/page-name/ (serves the correct page)
I wonder whether this is just because of a stricter Apache server on the remote server i've just uploaded it too, compared to that of my local environment.
Needless to say though it would be great to get a suggested fix in place :)
Please check below links.
wordpress mu 404 without end slash
http://yamz.wordpress.com/2009/09/21/trailing-slash-in-wordpress-permalink-causes-404-error-in-ie/
It will work , sure..
I have a two-part issue.
I am trying to implement a redirect only for the homepage URL to render with a trailing slash. Example: redirect www.domain.com to www.domain.com/ BUT allow all other URLs to render without a trailing slash.
End Goal:
www.domain.com/
www.domain.com/pages
www.domain.com/pages/post-name
This get complicated because there is one WordPress install with one .htaccess file but 6 other sites (with different domains) installed under the main WP install. I need to implement the trailing slash only on the homepage URL for a site that is mapped under the main install and shares the same .htaccess file with the main instal domain. So a rewrite base will only affect the main install domain, not the other 6 sites.
This is the first time I have encountered this kind of structure and it has me totally confused. Is this even possible to achieve? Thanks for any help!
There really is no need to force a trailing slash when there is no path, because if the path is empty, it is implied to be / already. Having the slash there or not will make absolutely no difference in the rendering of your pages or how Apache handles the request. Not to mention, redirecting users to have the / appended will just cause them to waste an extra HTTP request.
However, you can prevent Apache from adding the / to URLs which resemble a directory by using this:
DirectorySlash Off
Which will prevent /pages from becoming /pages/. Although, if a user manually types it in with the / at the end, it will still be there. Again, redirecting just to remove a / at the end is a waste.