I have created a subdomain(development.domain.com.np). Everytime when i hit the subdomain url it shows subdomain link but uses primary domain index.php file.
But when remove index.php file from my subdomain and replace it with index.html it works fine.
I am not able to figure out what is causing this.
I have checked redirects and logs but everything seems fine.
Do I have to add anything in htaccess file?. Any help is highly appreciated. Thank you.
You need to create 2 virtualhosts in your apache configuration pointing to 2 different documentRoots: one for each virtualhost. This way each virtualhost will handle just one domain: the documentRoot in each virtulahost will show only the files related to that specific domain.
Related
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/../
I have an apache server with some websites built in Wordpress, using vhosts.
The thing is that I have for all of them a configuration like:
ServerName site1.com
ServerAlias www.site1.com
When I access to Site1 through "site1.com" the URL changes to "www.site1.com". The same for Site2, Site3, etc. But for SiteN it's inverse. If I access to "siten.com" it keeps the URL and if you go to "www.siten.com" it changes to "siten.com".
I know I can change this using htaccess file, but my doubt is why some sites has a default and the new site has another default? All the htaccess have the same things and the vhost configuration is the same for all.
Thank you,
Done! The change should be implemented in Wordpress configuration, is not a htaccess issue
the goal
Redirecting mydomain.com/something to mysite.com/something
the problem
Any domain that you throw at the server gets 302 redirected to www.mysite.com and, for the life of me, I can't find the config rule that is doing this!
what i've done so far
I've grepped everything in the /etc/apache2 folder for 'mysite.com', 'Redirect', 'redirect', and other, as well as scour by hand all the apache config files looking for this redirect rule to no avail.
Any and all help in finding the culprit redirect is greatly appreciated. I'm not a sysadmin so there must be a place I don't know of where this might be other than the /etc/apache2 folder...
Thank you kindly for helping me with my first SO question :)
The file which includes redirection rules does not have to be in /etc/apache2 folder. Check your document root folder (the path of which you can find in your vhost configuration file) for .htaccess files. They may have redirect rules too.
The problem was with an .htaccess in the docroot of another domain on the server. This other domain was higher alphabetically and was treated as the default domain.
I solved the problem by creating a new vhost for the domain that i wanted to redirect and it was handled properly.
Thank you all for your help!
I need to point a subdomain (sub.example.com) to the same root as the main site (example.com). So when someone accesses sub.example.com, the same homepage is displayed.
I tried creating the subdomain and pointing it to /public_html instead of /public_html/sub, but if I access sub.example.com I get redirected to sub.example.com/cgi-sys/defaultwebpage.cgi, but if I access sub.example.com/index.php I get the right homepage.
My question is, how to properly point a subdomain to the root of the main site on cPanel?
Any help is very much appreciated.
cPanel redirect to "cgi-sys/defaultwebpage.cgi" when there is not index page present in document root. But as you said sub.example.com/index.php is working so I am not. Add the below lines in .htaccess in public_html folder and give it a try again. Create the .htaccess file if it's not present
DirectoryIndex index.php
Other option is to put a redirect for the subdomain with the domains homepage url
http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/ReDirects
First of all, sorry if I got the term 'pseudo subdomain' wrong.
what I am trying to achieve is this-
When someone registers on my application, they get a new url like..
yourname.myapp.tld
I dont want to use the subdomain system for this. To be frank, I dont know how the subdomains exactly work but it guess it requires a folder per subdomain inside the document root and then the server redirects the requests there.
Can this be achieved by doing something like -
when a visiter types any subdomain, (anything.myapp.tld), he is able to access myapp . In the index.php file i will explode the $_SERVER['HTTP_HOST'] to get the subdomain which i will store in session and will thereafter act as an identifier for that user. Ideally i wouldnt want to create any vhosts or add many lines to the hosts file. Can this be achieved with just one vhost?
Is this possible with mod rewrite or something ?
Yes you can archive this using wildcard that needs to be configured on both, the dns server and http server
On the dns a entry like this (installing dns on ubuntu https://help.ubuntu.com/10.04/serverguide/C/dns.html):
; wildcard subdomains are all directed to this IP
; of course this should be the IP of your web server
*.domain.tld. IN A 1.2.3.4
At apache an entry like this:
<VirtualHost 111.22.33.55>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
What happens after is that everything.domain.tld will be going to your main folder so you can use the index.php to redirect it to the right place or even an htaccess using mod_rewrite.