I have a website that's running correctly, now to setup a beta environment I copied the whole structure into a subfolder. So instead of var/www I have var/www/beta/.
This worked on my old server but on my new one its throwing me the "Unable to resolve the request" error. I've changed all the rights and checked the linking of the files. The main page shows up correctly but when clicking a link that goes deeper into the site it gives me the 404 error.
When I set the default controller a link will work. When I try to go to that url myself it will not, I'm thinking something is up with my urlManager ? (So www.website.com/xx/yy/2 wont work but defaulController = 'xx/yy/2'; and go to www.website.com will show the page)
Any help / insight would be appreciated.
If you're using apache, you'll need to update your RewriteBase, like this:
in var/www/beta/.htaccess, add:
RewriteEngine On
RewriteBase /beta/
This should do it.
Related
I am developing a project in which I want to show my custom error page for 404 error. The codes that I have used are working but not totally. So at first, I am showing the structure for my project then the problems I have.
My site name is www.example.com in which I have 4 files and a folder, files are index.php, about.php, error.php, .htaccess and folder name is admin.
In the admin folder I have lots of pages that I am loading with one single page in index.php. the URLs to access any page I am doing it with www.example.com/admin/index.php?page=login like this, so when page is login it shows me the login page.
Up to this everything is good, now I have used a code in .htaccess
ErrorDocument 404 /error.php
So after using it when I am trying to access a wrong URL such as www.example.com/abt.php it shows me the code written in error.php which is quite natural for my code.
So when I am trying to access again two wrong URLs like www.example.com/adminindex.php?page=login and www.example.com/admin/inx.php?page=login it is not showing me the code written in error.php rather it shows me just a message File Not Found.
I want that these two types of wrong URLs it should show me the code written in error.php.
Interestingly what I want is easily happens in localhost but not on in server.
I cannot understand why it is working perfectly fine in localhost but not on the server.
So how can I do that please help me to complete it?
I don't know that whether it can work for you or not? But you can give it a try i think it can resolve your issue which is quite similar to the previously asked question on stack overflow htaccess 404 page redirect not working for sub directory path
brilliantly answered by #anubhava. I hope it can help you to solve the issue. Also if the above does not help you out then you can also visit this 2 links SOLVED "File not found." instead of custom 404 file with php-fpm enabled & SOLVED "File not found" appears instead of 404.shtml (easy htaccess solution)
In fact there is no good method for that without using mod_rewrite.
The only solution would be to put another .htaccess to your /admin subdirectory (with a valid path for your error.php)
in httpd.conf file (the is in AppServ\Apache24\conf directory)
put this
ErrorDocument 404 /error.php
if not be ok try save the file as html
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 was working on a Wordpress website in our development server and everything was showing up correctly. I migrated the site to the live server and now NONE of the images are showing up. I have migrated a lot of Wordpress sites, but this time I can't seem to figure out what is going on.
Inside the posts, I have all the feature images set and they are all where they are supposed to be. When I inspect the code in the browser, I see that the loop is returning all the posts but the src, width, and height are empty for each item. The file that handles this template is the same in both locations so I am guessing it could be a database problem?
Here is the link to the development site: www.modpreview.com/mod
And this is the live site m.modworldwide.com
Any idea why this could be happening? Has anyone encountered this problem before? Any help would be appreciated!
Without more info, a guess for you:
Maybe check out the .htaccess in the webroot the site is being served from. Perhaps you are missing the line where the logic says "if the file exists, serve it, otherwise redirect to the php front controller"
which looks like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
This is possible to configure through the wordpress admin if your .htaccess has webserver write permissions, otherwise you need to manually edit it from the CLI or FTP or whatever you are using.
http://codex.wordpress.org/htaccess
I have a Wordpress site that works perfectly well in development (at mysite.dev), however when I deploy it to my remote server (mysite.com) it throws the 'This webpage has a redirect loop' error.
I can see in the loading bar that the browser is trying www.mysite.com then mysite.com then www.mysite.com again and again, however I'm not sure if this is relavant or not.
If my Wordpress database configuration is incorrect, I get the Error establishing a database connection message, however when everything is set correctly it breaks in this re-direct loop thing.
I have changed the field in the database (siteurl) to reflect the remote settings (http://mysite.com/wordpress).
Note: My wordpress files are stored in a folder called wordpress in my root directory except for wp-config.php, index.php and .htaccess.
Any ideas?
.htaccess contents:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
index.php:
<?php
/**
* #package WordPress
*/
define('WP_USE_THEMES', true);
require('./wordpress/wp-blog-header.php');
?>
My hosted server settings were forcing mysite.com to www.mysite.com and this was causing the problem. I turned this setting off and everything works now, i'd still like to know how to make it work with this setting turned on, though!
I had the exact same problem (a redirection loop after migrating to a new server).
But it was not a problem with the configuration values siteurl and home, neither was it an issue with the .htaccess file. I tried all that. And it was also not a problem about the 'www' added to the URL.
After some researchs I found that the loop was caused by infinite calls to the redirect_canonical function (in wp-inclue/canonical.php).
But it was not a bug from wordpress. Some Php configs set the $_SERVER['REQUEST_URI'] in a "wrong way" when you acces your root url. Example : On my server, when I go to http://example.com/ the $_SERVER['REQUEST_URI'] is set to '/index.php' instead of just '/'
This is confusing for redirect_canonical because this function always try to redirect to the "better" url it knows for a page. And the better url for the root of your site is '/'. On my server, each time redirect_canonical tried to redirect to '/' it failed, and tried again until an infinite redirect loop was found.
To correct this bug, you can either modify your server configuration - I don't personnaly know how to do that, but I know it is possible - or if you can't change it, just add this code in a custom plugin :
/**
* avoid redirection loop in redirect_canonical if REQUEST_URI
* contains '/index.php'
**/
/* remove the action set in the hook 'template_redirect' by wordpress */
remove_action('template_redirect', 'redirect_canonical');
/* set a custom action in the hook 'template_redirect' to check REQUEST_URI value */
add_action('template_redirect', 'correct_redirect_canonical');
/* Function to correct the behaviour of redirect_canonical */
function correct_redirect_canonical(){
if(strstr($_SERVER['REQUEST_URI'],'/index.php')===false){
redirect_canonical();
}
}
Hope it helps !
1.- As "My wordpress files are stored in a folder called wordpress" you must edit RewriteBase and RewriteRule like this:
RewriteBase /wordpress/
RewriteRule . /wordpress/index.php [L]
UPDATE
2.- Try cleaning all cookies. This simple action (through Firebug) has solved this problem to me sometimes.
UPDATE 3
3.- Try this /index.php in your root directory:
// index.php file in root directory
chdir('wordpress'); // change dir to WP
include 'index.php'; // execute WP with their normal `index.php`
and leave /wordpress directory as usual (with their normal index.php and .htaccess inside).
I mean don't change any bit of the normal index.php of WP that it is something like this:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* #package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* #var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
Note that the infinite redirection problem can also occur when using CloudFlare Flexible SSL. To fix it you need to install the following plugin:
https://wordpress.org/plugins/cloudflare-flexible-ssl
Are you using a plugin like Redirection which tracks URL changes?
This might have created a loop where it redirects mysite.dev/page/ to mysite.com/page/ and mysite.com to mysite.dev.
Happened to me before!
This error can happen in one of two places, on the user side, or on the admin side.
When it happens on the admin side (wp-admin), you will find that you are unable to login.
Step 1: Connect to your blog using ftp and navigate to your wp-content/plugins/ directory and download all of your plugins to a folder on your desktop.
Step 3: Still in your FTP program, delete all plugin folders and php files in the plugins directory. You do not want anything at all left in this directory.
Step 4: Try logging into your blog. It should let you log in with no problems. Visit the plugins section of your blog. This should load with a lot of errors telling you that each plugin has been deactivated due to an error. This is ok.
Step 5: Using your ftp program you should upload all your plugins. Once uploaded you should activate each plugin one by one within wordpress and then visit the wp-admin/ login address to make sure that it will pass you through to your blog once logged in.
Step 6: When you activate a plugin and start getting this error again, you will know which one is to blame. Simply delete that plugin via ftp and start looking for an alternative plugin to use.
If these steps do not fix your problem, you should backup all your wordpress files and then delete them. You should them upload clean wordpress files for the latest version and try logging in with no themes or plugins uploaded. You can upload these later once you can login.
If you continue getting error, clear your browser cache, test logging in with other browsers.
If all else fails, contact your webhost or open a thread on the wordpress support forum
First of all I'm just a beginner so...
Meanwhile I think that I may have an alternative/shortcut to this issue.
Instead of deleting every plugin and then reinstalling all of them one by one I suggest to start by deleting the lasted plugins because "resent problem = recent modification/plugins"...
That is just my suggestion.
Marco Davide
Though I found this post and solution really helpful because this problem was driving me crazy and took me so much time to realize. In my case it happened because I moved the files inside the same server but using another domain and after finishing all configurations and replacements I was not able to view pages and got this error.
In my hosting settings there was a Preferred domain filed which was set to domain.ltd (I tried to change it but finally left it so) and than in Settings->General wordpress dashboard I had WordPress Address (URL) "mysite.com" and Site Address (URL) set to "www.mysite.com" after setting last value without www..bum everything is okay now. Hope this helps anyone else
in my situation, locally - Openserver.
The problem appeared in capital letters in the address. For example, in the site settings it was http://local-Host, it was the capital letters that caused the problem, because the entire address is reduced to lowercase letters - http://local-host, and as result $redirect_url was different from $requested_url in canonical.php
I had the same problem, the answer was the .htaccess file and the redirects there. It seems that the theme/plugins I was using wanted its own code which was similar to that on the wordpress site for htaccess. I looked through the plugin and found the code it referenced and changed that in the htaccess file. Now it works.
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.