Apache - only main domain's root is not working - apache

I've created a new domain and setup a php application on the webroot. All the following requests are working perfectly.
/index.php
/info.php
/?anyting ( Note this, without index.php only query string is working )
/css/app.css
Only the domain's root is not working domian.in
I have created an virtual host for the domain. I tried giving DirectoryIndex index.php also, but still it's not working. There is no htaccess and it's a fresh server setup.
Googled whatever was possible, couldn't get any solution.
And if i hit domain.in it's serving the apache's default page.

If you have an virtual host you cant acces files outside the document root.
Maybe your html files (or others) are in a htdocs folder or something, you cant access htdocs/../

Related

Domain Name cannot be changed in Apache on CentOS 7

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!

Remove /public from URL in a subfolder

I'm building a Laravel application, and it will be in a subfolder of a current project. I'm trying to get rid of the /public in the URL, so that the users can view the project at this URL :
www.domain.com/project
instead of the default ...
www.domain.com/project/public
I did some digging on StackOverflow and the Laracasts forum, and I tried this, in a .htaccess file at the root of my project :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
However, my routes doesn't work anymore when I do this. Even the default route for / stopped working.
A lot of answers mention that the best way is to change the root in the Apache config, so that it serves the files from /public instead of at the root of the directory.
The problem is that this in a subfolder of a main project, how can I make it so that only this project is affected? The website at www.domain.com works fine and does not have a /public in the URL.
There are a couple options. I don't think you want to try fixing this at the htaccess level with mod rewrites (or anything like that)
One option is to create another virtual host that listens on an abitrary port (eg, 8080). Then set the document root for this virtual host to .../public/
Another option, you can spoof the dns in your /etc/hosts or Windows hosts file, and set up a dev.domain.com virtual host.
•Go to mainproject/public>>
a. .htacess
b. favicon.ico
c. index.php
d. robots.txt
e. web.config
1.cut these 5 files from public folder,and then paste on the main project folder that’s means out side of public folder… mainproject/files
2.Next after paste ,open index.php ,modify
•require __DIR__.'/…/bootstrap/autoload.php'; to
•require __DIR__.'/bootstrap/autoload.php';
modify
- $app = require_once DIR.'/../bootstrap/app.php'; to
- $app = require_once DIR.'/bootstrap/app.php';

http://localhost:80 class not registered

I installed Bitnami wamp stack, and, though my installation is reachable by http:// [nameofmylaptop]/site , i have the following error each time I launch apache :
http://localhost:80
Class not registered
I can't find anything relating to this..
Any help ? Thank you.
Have you tried: localhost/site, it could be that since your website is in a subfolder called site, localhost root directory has nothing to display.
#Husman Yeah it works.
Theres your problem then, there is nothing in the root folder, you can have an apache redirect to take you from localhost to localhost/site, and that should fix your issue.
There are multiple ways to redirect:
use a server side script (index.php)
use .htaccess rewrite rule
RewriteEngine On
RewriteRule ^$ /site[L]
use apache config httpd.conf to redirect from one folder to another
Redirect permanent / http://git.example.com/git/
...

Apache2 rewriting without rules

So i've a Wordpress site on my domain and i want to add subdomains with their own php code. I'm using mod_rewrite for wordpress and want to use it for my own projects but weirdly i can access urls that should result in a 404 error. For example i can access test/somestuff/morestuff and get test.php (without any $_GET set). But i have no .htaccess file in the directories for the virtual hosts. I then tried to delete the .htaccess from wordpress, restart apache2, and try again but i get the same behavior on the virtual host and wordpress doesn't work with permalinks (like i thought it would). My sites-available configs don't have any rewrite rules in them. Why can i access URLs that shouldn't work? Am i missing some feature of apache?
So after some more trying i've discovered the error was that i've had MultiViews enabled for the virtual host. I've disabled it and now it works.

Magic Apache redirecting for /~username

I have inherited a webserver already serving some websites. I am trying to migrate some of those sites to a new webserver.
One of those websites has a page called:
http://mydomain/ABCDepartment/
This URL also works:
http://mydomain/~joesmith
and the index page for joesmith actually lives in /var/www.../ABCDepartment/people/joesmith/
Now I am checking in httpd.conf and I see the following:
UseCanonicalName Off
UserDir public_html
UserDir disabled root
There are no special mod_rewrite rules for joesmith or the ~
How is this magic happening? UseCanonicalName is off, and if it wasn't UserDir public_html should look in /home/joesmith/public_html
What am I missing?
This is an Apache extension called userdir: http://httpd.apache.org/docs/1.3/mod/mod_userdir.html
It automatically rewrites requests to point to a folder called public_html within the user's home directory (the web server must have read access up the tree to this folder).