Domain Name cannot be changed in Apache on CentOS 7 - apache

I have set up a server with a wiki and Wordpress and Nextcloud on a new Domain, let's say it's testing.com. When I was finished, I wanted to change the Domain from testing.com to realdomain.com.
The server is running CentOS 7 with httpd (apache), so I changed the ServerName in /etc/httpd/conf/ to "realdomain.com". Then I changed the VirtualHosts in all the files in /etc/httpd/conf.d.
I added the new Domain to the trusted Domains of the Wordpress, Nextcloud and wiki. I restarted the httpd service and the server itself.
Yet, when I open realdomain.com in browser, it shows me my websites, but it puts testing.com in the address field.
I tried using mod_rewrite to change the URL, but then my webbrowser tells me that the site doesnt redirect correctly and that the redirects never stop.
I tried those rewrite rules in the .conf files and in the .htaccess (not simultaneously)- no success.
I removed all my files in conf.d and created a new DocumentRoot with a simple helloWorld.html - The Url still gets rewritten to testing.com.
Are there any other locations that could have rewrite rules? Did I miss anything?
Thank you so much in advance, this is killing me!

Related

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

Apache2 mod_write working for subdomain but not an IP address on same server

I have an Apache2 server running on CentOS 6.
There will be two subdomains running on this box.
sub1.domain.com
sub2.domain.com
For now the first subdomain is set up with DNS and mod_write working correctly. The second domain still has its DNS pointing to an older server and I will migrate the second domain's DNS to the new box's IP address.
Naturally I'm trying to test the new setup for sub2.domain.com before I migrate. I've configured the "default" web page for the box's IP address to have a document root which points to the future sub2.domain.com Laravel application.
mod_write rules in both .htaccess files are identical in both document roots and exactly match the recommended Laravel defaults.
Any insights appreciated as to why Apache2 would not process mod_write directives in an .htaccess file at a default document root accessed directly through an IP address much appreciated. I've combed through all the httpd.conf and vhost.conf files and nothing obvious sticks out as a likely culprit.
Thanks in advance for your help.

Apache webserver rewrite all URL's excluding some

I'm using apache httpd v2.2 server as a frontend proxy for our actual tomcat web server which hosts the Java web application.
I want to forward all urls received by apache webserver other than those having the prefix /product to tomcat.
I've tried the following set up in httpd.conf but it' doesn't seem to work
<VirtualHost *:6111>
ServerName localhost
RewriteEngine on
RewriteRule !^(/product($|/)) http://localhost:1234/$1
Alias /product /opt/productdoc
</VirtualHost>
I tried to follow Redirect site with .htaccess but exclude one folder but was not successful
Basically all http://localhost:6111/product urls should serve from hard drive (using alias)
Any other url should be forwarded to http://localhost:1234/<original-path>
You probably want to use something like mod_jk http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html.
There are a ton of examples and tutorials and it should be pretty simple to setup and install. Now that you know the name of the connection technology, you should probably be able to find more information.
Using modjk also allows you to secure your tomcat server and keep the public off of it.

Redirecting to Amazon EC2 AMI Instance

I'm trying to redirect a router to a certain PHP page stored on what I think is CentOS on my AMI (Amazon Machine Image). I've done a bit of research and have found that other people were having the same problem: I've looked here, and here and what I got was that I need an elastic IP for the instance that has the page I want to redirect to, but I already have that.
I've tried ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page, as well as (just the IP) xx.xxx.xxx.xxx/root/path/to/page and nothing seems to work. I'm so confused. I don't need a particular domain to redirect to my AMI so I don't need to map my domain's DNS to the elastic IP.
Okay, so I figured out the problem with the redirection. Essentially, I have Apache running on my CentOS AMI. As Apache, I think, handles most if not all HTTP requests, the request for the particular page on my AMI was being handled by Apache. What I did was that I looked in the configuration files of Apache on the AMI which are under etc/httpd/conf on CentOS at least (I don't know about other distributions), and opened httpd.conf (full path: /etc/httpd/conf/httpd.conf).
I looked for the particular line that had the DocumentRoot (this line sets the directory from which Apache will serve files) directive and saw that it had "DocumentRoot "/var/www/html".
What I was doing wrong was that my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page instead of just ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/page because I didn't know Apache was automatically appending /var/www/html before /page.
So since my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/page, when Apache was getting the request it would append another /var/www/html and look in ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/var/www/html/page.

MAMP, Apache, Wordpress and the case of the mysterious port number

I'm developing a few sites with Wordpress on a local server. I have my MAMP (2.0.1) running with the default port numbers for Apache and MySQL on Lion (10.7.2). It's been working quite well until I recently encountered a perplexing problem.
One site in particular has undergone a few internal domain/vhost changes (this is how I came to the conclusion of using the default port numbers re:my own Wordpress development) which are referenced in my /etc/hosts file and also in my MAMP apache httpd.conf VirtualHosts section. Now when I visit this particular development domain defined in the hosts and httpd.conf vhost, it gives me a browser error stating that it couldn't establish a connection to dev.example.com:8888 (the Wordpress index.php and htaccess files are in the folder index). I'm a bit annoyed and confused as I've changed the MAMP ports to the default, yet this references the 8888 default MAMP apache port only on the domain index and doesn't want to sway its course even if I visit dev.example.com:80. I can access files and folders within the domain by specifically typing them in, but visiting the domain index as it is gives me this error with the default port number. I have no idea why that is and haven't been able to find a solution via the internet.
Some search results have mentioned incorrect line formats in the hosts and httpd.conf files, but mine are all Unix LF based so that solution hasn't made a difference. I've removed Wordpress from the domain's folder structure and tried again but it still gives me the same error. On another domain I'm using with Wordpress it works fine; the folders are set up exactly the same way, as are the entries in the hosts and the httpd.conf files. I get no apache errors when I visit the particular erroring domain as well. I'm just a bit stumped on the whole thing.
Hosts entry:
127.0.0.1 dev.example.com
Vhost entry:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName dev.example.com
DocumentRoot "/Sites/example.com"
</VirtualHost>
Wordpress config:
sql.wp_options.siteurl = http://dev.example.com/wp
sql.wp_options.home = http://dev.example.com/