Redirecting subdomain URL to specific URL - apache

On my site, each group has a specific URL, eg: domain.com/my-group, domain.com/my-group2 and so on..
What I would like is that the user uses my-group.domain.com, my-group2.domain.com to get to its group.
How can I achieve that?

You can setup Apache to listen on both  my-group.domain.com and my-group2.domain.com using the Virtual Host configuration.
Apache's documentation on this topic should be enough to get you started:
https://httpd.apache.org/docs/current/vhosts/

Related

Redirect from a URL to a other server

I have the following question that I do not know how to solve it in the most efficient way.
I have two servers, one with Apache where I have a Wordpress instance responding for port 80, and on another server I have a Wildfly with another application listening on port 8080. The Wordpress that I have configured on the Apache server, responds to the URL http://www.somedomain.com What I'm not so clear about is how to do when a request arrives at http://www.somedomain.com/yyyy and redirects me to the Wildfly server where an application is responding to the URL : 8080 / app
How could I do it in the most effective way? Using the rewrite module in the .htaccess file or using the Apache proxy module and configuring it in the Apache virtual host? How would I have to do it?
Thank you very much in advance.
You're mixing a few things that are not related to each other. First of all, a redirect is something different than a proxy. Redirecting means asking the client (browser) to look at another URL. A proxy, on the other hand, retrieves the content of the other URL itself and passes it to the client. Using a proxy, the other URL remains invisible to the client.
Second, mod_rewrite is not limited to htaccess configuration. In fact it's better to configure mod_rewrite in the virtual host configuration, just as you suggested with the proxy configuration.
The htaccess is simply for users who are not allowed to mess with the server configuration itself. Configuration in the htaccess can be limited by the admin for security purposes at the cost of slowing down the server.
That said, if you are looking to map your wildfly server paths into your main server's paths, you might want to use something like this inside your main server's virtual host block:
<Location "/yyyy">
ProxyPass "http://wildfly:8080/app"
</Location>
See http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass for detailed explanations.

Subdomain redirect when using HTTPS

My website runs on WooCommerce in public_html. I have a Subdomain in a public_html/sub. When I try to access the sub using HTTPS it seems to redirect to /wp-admin. I'm using the default URL rewrites that come with WooCommerce. How can I fix this issue?
Look at the Apache Config / Vhosts etc.
Basically, search for *:443 in the configuration file (or [ipaddress]:443 if you have fixed IP addresses associated with your server).
This will explain the difference in behaviour.

apache system-redirects.conf one domain to another

I want to configure my apache system-redirects.conf to redirect from:
www.example.com/mail -> www.example2.net/mail
So i want to have both domains, but i want that my co-workers access to only one webmail link.
I tried this:
Redirect permanent http://www.example.com/mail http://www.example2.net/mail
Didn't work, what am i doing wrong?
Thanks for the help.

IP address is shown in address bar instead of domain

I have a WAMP home web server up and running on a static IP and registered a domain with Namecheap, but I'm a bit shaky with DNS. At first I used URL Redirect and pointed it to my IP. This meant that when you typed in the domain (like example.com) it just redirected you right to my IP, replacing the domain name with it in the address bar. Now I'm trying to get the domain to show instead of the IP in the address bar, which I'm struggling to understand exactly how to do.
The latest thing I've tried which many people say to do is instead of using URL Redirect to use the A (Address) record type and point it to my IP, which I thought would finally fix my problems. Of course after 15 min or so when it all got updated I'm getting a 400 Bad Request with nginx under it in Firefox, and a blank page in Chrome. Now I'm getting blank pages in both. Did I do something wrong here? Do I need to edit something on the web server such as httpd.conf? Am I going at this completely wrong?
Yes you should do away with the redirect and instead create an "A record". The sub-domain entry would typically be, but is not restricted to "www". The record type "A" and destination/target would be your external IP address. Once you update this record it may take several hours before you notice it taking effecting, upon where on people typing your URL would be directed to your web server.
You will need to forward port 80 on your router to the server hosting WAMP.
Finally the WAMP server should be provided with your domain name so it knows which site to load. If use the VirtualHost file this will allow you to host multiple domains on your web server. To do this...
Uncomment the following line so it appears like below in your Apache httpd.conf, to allow Apache to use virutal hosts
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then locate the httpd-vhosts.conf file, should be found in your WAMP installation location, such as C:\wamp\bin\apache\apache*version_number*\conf\extra\
Add an entry for your site, altering the details to your own domain name and website location.
<VirtualHost *:80>
ServerName www.stackoverflow.com
ServerAlias stackoverflow.com
DocumentRoot "C:/websites/stackoverflow/"
ErrorLog "C:/websites/stackoverflow/logs/error.log"
CustomLog "C:/websites/stackoverflow/logs/access.log" common
</VirtualHost>
Now restart your WAMP server and give it a whirl.
Tip: If your server won't start after these changes, check that you have created the folder structure for the log files!
Solution described here could resolve this issue.
Most of the free dynamic dns providers, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org.
Now, go and configure your free domain names in the dashboard of free provider in the following way (assume your IP is 188.165.15.29 and your server's listening to port 8085).
redirect mysite1.somefree.org to mysite2.somefree.org:8085
redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29
This also works when you are using Apache httpd server alone, not being part of WAMP. You do not need to tweak virtual host or any part of your server. You only configure inbound direction.
Use Forward with masking where you registered your domain. mine is GoDaddy.
in the forward settings, you will see this at bottom of the page. click Forward with masking and add the title you want them to see in the address bar of the browser when they go to your site. instead of showing your IP address

Google API - Redirect URI with an internal IP

I'm creating an app using Google calendar API. Everything works fine on my local apache install, using localhost:8888/pathtoapp as the redirect URI.
I want to migrate the app to another machine on my local network. I tried changing the URI to the local ip of the new apache install. I get the following error...
Error: invalid_request
Invalid parameter value for redirect_uri: Raw IP addresses not allowed: http://192.168.0.17/pathtoapp/
Any ideas on how I can use an internal IP as a redirect URI or other ways around it?
Thanks.
Looks like the API is not allowing you to use IP addresses. Try to use network name not ip address.
If you don't have access to the name, create an alias on your local machine for that specific IP.
[development environment suitable solution]
Whilst the Google Console will not allow you to have an IP as a redirect URI:
Invalid Redirect: http://10.100.1.1 must end with a public top-level domain (such as .com or .org)
you can create a host name entry which redirect you a valid domain to another the desired IP address:
$ vim /etc/hosts
Append:
10.100.1.1 localhost.com www.localhost.com
Now you can access your site from localhost.com or www.localhost.com and have localhost.com as the redirect URI.
It's not possible...you have to stick in a domain name on a public server for testing...seems stupid to me as well :-P
Duplicate of this:
Can a public IP address be used as Google OAuth redirect URI?
Use localhost:port/redirectpath to test on local machine.
For window OS, this error can be removed by adding host entry in your system so google will think it as coming from the given hostname
Take your global IP address say: 106.200.247.101 (or google what is my IP, you will get it)
go to C:\Windows\System32\drivers\etc\hosts on windows and add a new entry as below
eg:
106.200.247.101 abc.com
Then you will be able to refer to using given hostname