How to make a link redirect to external URL in middleman - middleman

How to make example.com/go/link/ redirect to example1.com/go/link/ in middleman.
How do I maintain a list of redirects like that?

Related

Apache rewrite url and hide old url

I want to simplfy an URL but cant find how to do that.
Here is the original URL that exists and works.
https://example.com/s/732kglm
I want to use this different URL for the same content.
https://example.com/info
I can do that in apache with a redirect
Redirect permanent /info /s/732kglm
Now if I open https://example.com/info I will be redirected to https://example.com/s/732kglm but the browser shows the original URL.
I want to hide tho original URL so that user only sees the simplified URL https://example.com/info
How can I achieve this?
It sounds like you need an internal redirect. I don't have access to apache to test, but something like the following should work.
RewriteEngine on
RewriteRule "^/info$" "/s/732kglm"

Redirect a specific single web page from one domain to a specific web page under another domain

How do I get the following redirect to work?
The old address contains URL parameters:
olddomain.com/Index.asp?CategoryID=2379&ArticleID=6592
And needed to redirect to a regular URL under the new domain:
newdomain.com/example-page
Can I do it via mod_rewrite on on my .htaccess file? what is the correct command for this redirection?
I will need to do that for each page under the old domain (the target URL under the new domain will be different for each page)
Actually nothing, the only solution I found was to redirect the entire domain to the new domain, without redirecting each page to it's target.

Apache redirect to https and modify url structure

Goal:
Redirect from http://example.com/library/page123.htm
to https://example.com/library/folder/page123.htm
I have found plenty of example on how to perform redirects to ssl and how to add folders, but am struggling to execute these together. Additionally, there are multiple pages under the "library" folder of the old url structure.
Appreciate any help!

Multiple Domains to Display Content from Landing Pages on Another Domain

We have created a bunch of landing pages on a Joomla CMS system, such that the URL for each landing page is www.domain.com/page1.html and www.domain.com/page2.html, and so on. Of course the page1.html isn't really an HTML file it is a dynamic CMS page, just rewritten with htaccess.
The goal is to have one of our other domains, something like www.uniquedomain1.com show the content of www.domain.com/page1.html. Or, another domain like www.uniquedomain2.html show the content of www.domain.com/page2.html.
This needs to be search engine friendly so we can't use URL masking. Also we can't use HTACCESS redirects as this actually changes the URL in the browser bar. Need to keep the www.uniquedomain1.com URL in the browser bar.
Tried Apache VirtualHost options without any luck. You can park in a directory but not from a URL.
Ended up parking the domains on one folder, and then creating a PHP script to detect the domain host and then use CURL to query the correct url and deliver content. This whole thing seems ridiculously over complicated, and of course CURL isn't the best option, but it is all we could get to work.
Any thoughts on how to do this, or a better solution?
You can use HTACCESS redirect rules to do it without performing a redirect.
Change the html file names to be the domain name of the desired domain like domain.tld and do something like this in an .htaccess file
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?([a-z0-9\.-]+\.[a-z]+) [NC]
RewriteRule ^$ /%1.html [L]
A quick test of this worked for two of my test (sub)domains test.domain.tld and test2.domain.tld. Both properly redirected to files with the names test.domain.tld.html and test2.domain.tld.html without modifying the URL.
You could also just use your PHP wrapper script to grab the content of each of the miscellaneous html files and output them.
If you renamed all of your HTML files (as in my previous suggested answer) to be domain.tld.html you could do it fairly easily. Something might look like:
<?php
require($_SERVER['SERVER_NAME'] .'.html');

rewrite url without change address

I want to show a page instead of another page, without change the second page url.
I know this is possible with htaccess.
I copied that code from a cms htaccess:
RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]
with that code, we will redirect to calendar.php?......... but I want it redirect (without changing the address in address bar) to another site, for example to http://www.google.com/page......
Is it possible?
Thanks ..
If you want to provide content from another site without changing the address in the address bar of the browser that mean you becomes a proxy.
So check apache documention for proxy configuration (this can be done for specific urls only). Even mod_rewrite can do the proxy things with the [P] tag, mod_rewrite will allow a lot more 'specific url' filtering.
Now the job of a proxy, when he have the response from the distant website and he needs to render it for the HTTP client, is only to change the HTTP headers in the response. So only url in Location tags or such specific headers will be altered. You must known that all the HTML content from the distant website will not be altered (the inner links will be on www.google.com and not on your www.whythehelldoiproxygooglewithmysite.com).
If you want to alter this returned content check mod_proxy_html module, this will add some extra stuff before sending the resonse, to do some more reverse proxy alterations.