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.
Related
I am working on a website that has many directories and subdirectories. Developing locally, I am running php's built in webserver. I really like the way this handles 404s in that if a 404 is found, it serves the parent directory, but maintains the url so that I may parse it and perform some task.
For example:
Given: dir4 does not exist
localhost:8000/dir1/dir2/dir3/dir4/
This URL will return the index.php found in dir3, however the URL will remain the same, and I can use dir4 to determine some login on the dir3 index file (looking at $_SERVER['REQUEST_URI']).
The behavior is also outlined here.
When I move my project onto my webserver, this did not work.
I've tried the solution posted here but it removed the "dir4" part of the URL.
I am hoping to recreate this functionality via .htaccess. Has anyone successfully done so?
I have an installed WordPress website.
I'm working on the site, therefore, I want to show a constructor page for the internet user. I have created a page which called first.html and I change the .htaccess file like below
#Alternate default index page
DirectoryIndex first.html
Now when I enter my domain name on the browser I can see the first.html. This is working properly.
I'd like to see my changes by entering the domain and page name on the browser like
www.mydomain/index.php
or
www.mydomain/wp-content/themes/XXXTHEME/index.php
However, my theme pages don't work.
How can I achieve to do this?
Instead of making changes in .htaccess, I'd suggest you to use this plugin : https://wordpress.org/plugins/maintenance/
Simply name your html file "index.html"
Web servers most commonly parse the index.html file firstly (unless told otherwise) and if it is not found, it proceeds to index.php
This also allows you to simply change that ".html" part to ".php" to see the website you are working on, without installing plugins that clutter your database or making unnecessary changes to your .htaccess file.
I have a cakephp 3 script installed on my cpanel account.
this domain is the primary domain for account but i have relocated it to a subfolder for necessary reasons.
my htaccess rewrites it perfectly and every url works both with and without /subfolder/ in the url.
However, all the links in cakephp automatically append /subfolder/ back into the url.
I even tried manually replacing $base_url in configuration.php with 'mydomain.com'; only, but that didn't work. Then I replaced every instance in all the hundreds of files of $base_url with 'mydomain.com'; but still, nothing changed and it still shows that /subfolder/ in every url even when i access mydomain.com directly._
I need to get rid of this /subfolder/ in the url that cakephp is serving from php. i tried everything i knew but nothing works.
Please tell me how to solve this problem.
Have you tried setting App.base, App.webroot? Setting those values up will disable automatic directory detection and should help you get the URLs you want. See configuration docs for more on those values.
At the moment I am trying to move a website to a new web server. The site uses CodeIgniter and on the old server, every route worked. On the new server none of them are working, even though I copied the entire website from the old server. This means there are no differences in .htaccess files, since the two servers contain the exact same website. Not even the default routes are working, just the home page (index.php). I included the code in .htaccess to remove 'index.php' from routed URLs, but that also does not work.
If I try to visit '1.1.1.1/~user/employees' it will give me a 404 error, which means that the CodeIgniter route is not working. The controller file is located at /application/controllers/employees.php, so I am not sure what causes the problem.
I am aware of the similar posts on the site here, but none of them could solve my problem. Configuration of the config/config.php is (partly) as follows:
$config['base_url'] = '1.1.1.1/~user';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
I have tried to change the base_url, but it still does not work if it's empty. Changing uri_protocol to REQUEST_URI or PATH_INFO also does not work. Also, if I try 1.1.1.1/~user/index.php/employees (so put 'index.php/' in between) I still cannot reach the page. I checked some Apache settings as well, AllowOverride is set to ALL and the mod_rewrite module is installed and enabled. Is there perhaps something else concerning differences in both server's configurations that I could have missed?
EDIT:
I think I am a bit closer to finding out what the problem is. It is either something with Apache or .htaccess (but I already tried many things) or it has to do with the fact that the server URL is 1.1.1.1/~user rather than 2.2.2.2 as it was on the old server. Maybe I should change the baseurl or location of my .htaccess? This looks similar to my problem, but moving the .htaccess did not fix the problem: Url routing errors in php in codeigniter. I might try re-installing Apache.
I think that you firstly should find out what happened.
All requests to CI go through index.php, so you just echo something and exit in index.php file at the first line.
If the page display what you echoed that means there is something wrong in CI, otherwise that's not because of CI. And you can focus on what cause the problem.
Sorry about my English.
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.