78
votes
Accepted
Why can I update a file owned by root using sudo vi, but not append a line to it with sudo echo "Thing" >> file?
Sudo elevates the process it calls, it does not elevate any of the current shell's processing like redirection, globbing, etc.
The file redirection >> /etc/httpd/conf.d/vhosts.conf is being ...
- 130k
45
votes
Accepted
How can I redirect an entire site to a single page?
If you are "shutting down a site" then you probably should not be "redirecting" the old site pages to a single page. An HTTP redirect sends a 301 response code, informing users and ...
- 12.1k
27
votes
Prevent port change on redirect in nginx
I my case nginx listens to port 80 inside a docker container but it's mapped to port 8080 (or any random port) outside the container. There is no reverse proxy in-between that can add proper headers ...
- 411
8
votes
Accepted
Using iptables port redirection with docker
A possible modification to the iptables rules is to remove both and replace with:
iptables -t nat -A PREROUTING -p tcp -m tcp -i eth0 --dport 80 -j REDIRECT --to-ports 8080
This will ensure that, ...
- 373
7
votes
Accepted
Redirect DNS requests for 8.8.8.8 to a local DNS inside a LAN
Remeber 8.8.8.8 is an anycast address. You can basically do the exactly same thing Google does for maintaining one of their boxes that serve the 8.8.8.8 traffic.
Assign the IP address 8.8.8.8 as an ...
- 130k
7
votes
Accepted
Fix missing ssl-cert for subdomain www. using redirect or similar
You cannot solve this without getting new SSL certificates. Redirection won't help, since the SSL certificate is getting checked before the actual HTTP session starts. ETA So you need new certificates,...
- 27.6k
5
votes
Accepted
lxc-attach command with redirection
As @jordanm said (see comments), this one works:
lxc-attach -n 101 -- bash -c 'echo "auto lo" > /etc/network/interfaces'
- 192
5
votes
Accepted
Using Apache RedirectPermanent to send all requests to a specific subfolder
Redirect is not the correct one to use for what you seek. Redirect redirects "all" and "appends that all" to the destination, but you want a final single destination, so.. use this instead:
...
- 2,340
4
votes
How to quick and easy remove part of an URL in Nginx with HttpRewriteModule?
Depending where you define the rewrite directive you have two ways to implement it:
A. In the server context
server {
...
rewrite ^/component(.*)$ $1 last;
...
}
B. In the location ...
- 143
4
votes
Accepted
Nginx: Redirect URL to always include a locale prefix
Explain to me why my configuration has not had the intended effect so
I can understand it and not repeat the same errors in the future
location ^/en/(.*) is not a valid directive.
You might have ...
- 13.1k
4
votes
Accepted
Redirect domain and all the subdomains to a certain sub domain
I think the most important thing to note is that the actual redirection that you describe will not be done in DNS.
You could do something like this (minimally):
example.com. IN A 178.62....
- 34.4k
4
votes
Accepted
haproxy redirect custom http traffic to a custom https port
Either remove port from redirect or replace-value
http-request replace-value Host (.*):7777 \1
http-request redirect location https://%[req.hdr(Host)]:9999%[capture.req.uri] if is7777
OR
http-...
3
votes
Nginx: How to redirect domain on lang?
Updated the answer based on clarified requirements. That's a pretty weird way of having your websites set up. My first suggestion is put in a more sensible structure, where all sites are on one domain,...
- 31.2k
3
votes
Redirect to language specific domain - Apache 2.4
You just need to add another rule as other are:
RewriteCond %{HTTP_HOST} ^(www\.)?domena\.com
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^(.*)$ http://domena.pl/en [R=303,NC,L]
You need to add ...
- 3,033
3
votes
Redirect subdomain to subdomain Apache2
I believe you can solve this by setting up 2 vhosts:
<VirtualHost *:80>
ServerName inf.xyz.city.eu
ServerAlias www.inf.xyz.city.eu
Redirect / http://sth.city.eu/
</VirtualHost>...
- 153
3
votes
.htaccess - redirect non www to www and retain subdomains from redirecting
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This works for all domains, excluding any subdomains. have ...
- 31
3
votes
Accepted
HTTP to HTTPS rewrite not working the first time
The variable HTTP_POST doesn't exist. You most probably meant HTTP_HOST:
RewriteEngine on
ReWriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
Since this is a permanent redirect the response code ...
- 21.8k
3
votes
Accepted
hosting multiple websites on multiple servers with a single outside IP address
Exactly. You need one http endpoint that takes the requests and then forwards the requests to the appropiate server on the inside. This is the very definition of a reverse proxy.
Note that this means ...
- 51.4k
3
votes
Accepted
How can I redirect domain A to domain B without hosting, using only DNS records?
Redirects cannot be done with DNS only.
However, some providers have HTTP redirect services that are configured via same interface as DNS. These support only HTTP. HTTPS support requires valid ...
- 36.1k
3
votes
How can I redirect domain A to domain B without hosting, using only DNS records?
Another option is such as https://forwarddomain.net/ which (kindly) gives a free redirect service using only DNS records. An example below redirects from sub.example.com to othersite.com
sub.example....
- 186
2
votes
Prevent port change on redirect in nginx
For those who have
Varnish listens port 80
backend server (in my case nginx) listens port 8080
The fastcgi_param SERVER_PORT should be same as the frontend.
So, I set
fastcgi_param SERVER_PORT ...
- 121
2
votes
Someone seems to be redirecting to my site
So, your domain points to the IP Address 66.228.40.84 which is obviously your web server. The admin for the other domain (xmit.io) has pointed their domain to the same IP Address. This is probably not ...
- 5,367
2
votes
Selectively redirect to HTTPS using HAProxy
I went for the following which works perfectly in my case:
frontend yadayada
...
acl Secure dst_port 443
acl Login path_beg /login
redirect scheme https code 301 if Login !Secure
- 199
2
votes
Accepted
How do I persuade Nginx to redirect all requests except /robots.txt?
Thanks to gf_ and Drifter104 for the comments. Drifter104's comment about matching the location got me looking into the different matching patterns and eventually landing on the config below.
# Media ...
- 53
2
votes
Why do redirects from my subdomain end up on my primary domain?
When using both an F5 and apache mod_rewrite and/or mod_proxy, where should subdomain handling, redirection, and/or SSL configurations be managed?
As long as you decide to do so in one single ...
- 74k
2
votes
How do I remove the www from my domain URL
This can be achieved by Rewrite Valve, it's pretty similar to mod_rewrite in httpd :
1- Include rewrite valve in your global context file context.xml or your host context server.xml , I recommend it ...
- 241
2
votes
I'm getting Permission Denied when redirecting output from CMD to a text file using the logitech_dfu tool
Can you check if you can create a file through Windows (File)Explorer in c:\temp without getting a so called UAC prompt?
- 139
2
votes
I'm getting Permission Denied when redirecting output from CMD to a text file using the logitech_dfu tool
Unless this is a very old machine you're running on, the "TEMP" directory isn't where you think it is; not any more.
Try using the %TEMP% environment variable instead.
Logitech_dfu --output "%TEMP%...
- 1,449
2
votes
Accepted
Redirect from one domain name to another for the same website with IIS
You can use URL rewrite module
<rule name="CanonicalHostNameRule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(.*)$" />
...
2
votes
How can I redirect an entire site to a single page?
The reason http://www.example.com/ is working and https://www.example.com/doesnotexist.html isn't is because your rewrite condition explicitly disables the rewriting if the client is accessing the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
redirection × 321nginx × 50
redirect × 43
apache-2.2 × 36
.htaccess × 33
domain-name-system × 22
subdomain × 18
301-redirect × 18
linux × 17
iptables × 17
mod-rewrite × 16
rewrite × 14
port × 14
apache-2.4 × 13
https × 13
ssl × 12
iis × 11
windows × 10
bash × 10
haproxy × 10
domain × 9
networking × 8
ssh × 8
php × 8
email × 8