Can't access php files in folder using XAMPP - php

I have troubles accessing my php files in a folder. When I click on the folder, it brings me to a page on chrome which says "Bad data passed, return to home (which is a hyperlink to the actual website)". Then when I click on the hyperlink, it runs on an online server of the main page instead of localhost. How do I fix this problem?

You need to resolve the host to your local ip in the hosts file, in /etc/hosts add at the end of the file
127.0.0.1 yourdomain.com
127.0.0.1 www.yourdomain.com
where yourdomaoin.com is your domain. Put also the www subdomain if you use it

You may have problems with .htaccess (in root public_hrml folder). Try to rename it to .htaccess_backup and check again.
If that doesnt help, post here exactly what url you are being redirected to.

Related

Webiste url are not routing without index.php

I uploaded my website from my UAT/Test domain to EC2 AWS. Before everything was fine, but now only home page opens.
And if I try to navigate to any other links I can't, it gives following error
The requested URL /page/company was not found on this server.
But when I insert index.php in between it works fine.
Any ideas?
Please enable mod_rewrite module in your server and rewrite index.php in htaccess file.
Please check your file premissions
I believe the issue could be DirectoryIndex which apache (not positive that is what you are using as web server) uses to direct the user to a specific file if a directory is selected in the URL.
This can be set in your apache config if you have access, or in a .htaccess file if you only have access to the your webspace itself.
http://www.htaccess-guide.com/directoryindex-uses/
Basically with DirectoryIndex you can tell apache to automatically use index.php, or index.html, or really whatever file you want to be used when no file in a directory is given in the URL.

PHP page in the wwwroot folder

I am trying to upload my localhost site that I am making to the live server. Before I did that I made a test with a "hello world" index.php
When I place my index.php on the following path the page is working:
but that is not in the wwwroot.
When I place the index.php in the wwwroot folder I do not get to the hello world page. I just get the domain page.
How can this be? I also noticed that my page should be dangerous in the URL bar. It is just a portfolio, there is nothing dangerous on that site.
According to discussion in comment,
You need to set/change your DOCUMENT_ROOT directive as below
DOCUMENT_ROOT /customers/0/f/c/vouzalis.com/httpd.www
to
DOCUMENT_ROOT /customers/0/f/c/vouzalis.com/httpd.www/wwwroot
If you are not managing your server, you can ask hosting for setup.
You need to verify your Apache VirtualHost configuration. You need something like:
DocumentRoot /wwwroot/

Sub-pages always open domain root

I'm having a strange problem with a new PHP page I´m writing. Everything seems to be loading/redirected to the domain root page.
domain.com loads fine
domain.com/page or domain.com/page/index.php always loads "domain.com" while retaining the /page/index.php in the browser URL.
Even domain.com/some_random_text loads "domain.com"
I suspected the .htaccess file, but there is none to be found. There are no redirects in the PHP code.
If I remove the domain.com/index.php file I get an Internal Server Error when opening domain.com/page/index.php
This domain did have Wordpress installed, but I did uninstall that via cPanel.
First thing to notice is that the .htaccess file can be anywhere in the path that is handled by Apache. So check everywhere. This kind of redirect could be made only like that.
This can only be done by Apache, so you might also like to check the apache config if you are running on a virtual machine or dedicated server.
Also, not that it might have been a wildcard redirect, added by the cPanel, so check those settings. Though I think those actually just modify the root .htaccess file.
Based on the data you provided I cannot say more, but I don't think this is a common issue.

How to get absolute path of image and includes files with 2 different domains And different document root folder

I have two domains.
Www.abc.com
Www.xyz.com
Now, I have one domain hosted at my cloud server, which is www.abc.com
And I have a folder in www.abc.com = www.abc.com/appFolder/app1/
Now I have hosted my another domain at the same cloud server using virtual host configuration in apache with document root folder for this domain to point out: at the above folder.
So basically when somebody is going to www.xyz.com then they are viewing the page at www.abc.com/appFolder/app1/
My problem is, I have database connection config file situated at the root folder, i.e. At www.abc.com So this is why when I go to my abc.com everything works fine. But now in case of xyz.com it is unable to find the config file??
How i can use config file there?? Also in case of accessing the image.
If I am in abc.com then I can access file by doing ../../image.jpg but in case of xyz.com it is not able to find the image file by doing this. I understand it is because of different document root folders. But is there any way that I can deal with this issue??
It should not change anything for your database connection. Config files are accessed with local paths. They are not related to domains.
For images, you could use absolute url and load images on www.abc.com even if users are on www.xyz.com. Or, you can detect url in request prameter and adjust paths. A simple in the header can define base url for all links in your page.

Why would index.php only work some of the time?

I just moved a develoment site onto a test production server and I'm testing some things out.
When you go to the root URL (ie rooturl.com), the browser is correctly rendering rooturl.com/index.php without showing the index.php in the address bar.
However, I also have a directory at rooturl.com/admin that also has an index file of index.php, but when I go to rooturl.com/admin I'm getting a 404 not found error. But if I type out rooturl.com/admin/index.php, it loads the page.
Is there a common reason for this?
The last piece of relevant information is that since my client won't switch their domain name to the new host until they are ready with migrating email, etc., I'm currently not able to view the site on the registered URL, I can only access it using the IP address directly which I got from the host.
My gut feeling is that the direct IP address is screwing with how it would normally work, but it's just a guess and I have no idea why that would be the case.
Sounds like it could be an .htaccess rewriting issue. Be sure to check any .htaccess file (hidden, by default) in those directories for any screwy rewrite-rules.
If you're running a MVC project, then the url /admin may be confused for a call to a controller rather than a directory.
My first shoot is that you have .htaccess file and it is redirecting everythind to your root index.php file.

Categories