This website was in one server, and that server failed, so an automatic backup has made. the problem is that now it looks like a lot of files are missing, if I check the console in the browser there is a lot of 404 errors, and the requested URL is wrong.
Is there a kind of configuration file in which I can set the url that wordpress should use to request the files?
Update:
Only the .js, .css and .png files are wrong requested, the .php and .html files are fine.
It may be an issue with the trailing slash into the home URL and site URL. The URL should be "example.com". Add the slash in the last of the website URL.
Try with adding a trailing slash in the site URL and home URL.
I fixed it, the file I was searching for is wp-config.php, and the line that did the trick is
define('WP_SITEURL', 'http://example.com');
I don't know what was the problem, but I basically solved it overwriting that config variable.
Related
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.
We're having a problem with our PHP site: http://midlandssmilecentres.co.uk/
The problem is as follows, if you were to access, for example http://midlandssmilecentres.co.uk/feedback.php, and then put a trailing slash, it returns the index page of the root directory. From there, you can actually put any page, i.e. http://midlandssmilecentres.co.uk/feedback.php/feedback.php, and it will return that page. We need this behaviour to stop, or a feasible work around to stop these pages being accessible.
This is causing us lots of problems with duplicate content and pages that haven't been mobilised, due to the page trying to fetch the CSS from the wrong directory. We've tried removing all of the .htaccess files on the server, however this has not fixed the issue. I've done plenty of research on files with trailing slashes and how a file can be interpreted as a directory, but couldn't find anything that could help me with this.
With .htaccess, you can redirect all .php/... pages:
RewriteEngine on
RewriteRule ^(.+?\.php)/ $1 [NC,L,R=301]
You also can change the apache configuration with:
AcceptPathInfo Off
But in this case a 404 error will be returned
https://httpd.apache.org/docs/2.2/mod/core.html#acceptpathinfo
I think you need to set a 404 REDIRECT, so instead of returning that page, it redirects to a 404 page.
In my webserver, I have created a .htaccess file with the following lines to redirect the wrong/missing URLs (Error 404), to the php file not_found.php. It works fine.
ErrorDocument 404 http://myserver.edu.in/not_found.php
Can I able to capture list of wrong/missing URLs into a text file (or) display the wrong/missing URL in the error page not_found.php itself?
I tried the PHP variable $_SERVER['REQUEST_URI'] in the not_found.php file to capture the wrong/missing URLs. Now I have two issues.
Since I have used the full URL of the error page in .htaccess, it fails. If I change it to ErrorDocument 404 /not_found.php. It works fine only inside the same directory.
In the not_found.php file, I have used include_once function to include header, footer, images, and scripts. So, If I change the .htaccess to ErrorDocument 404 /not_found.php, the error page not_found.php does not display properly in the different directory.
For example, http://myserver.edu.in/xxx/trial.php
In this case, I used full URL for images and scripts. But, not able to use full URL for PHP files using include_once function.
Can anybody suggest some better ideas to solve this issue?
With the ErrorDocument directive, Apache also sets some special environment variables, for example:
REDIRECT_URL
REDIRECT_QUERY_STRING
These should be available if (as you already noticed) the error document does not have a path starting with http. Thus, you can store the not found requests in your database or some text file.
However, $_SERVER["REQUEST_URI"] is available as well, I am using it in a similar case to redirect requests to another domain, if the file is not on that specific server.
You need to rewrite the missing urls, or even better, you could use PHP to include the not_found.php file. The problem with redirecting that that search engines will think that the directory /not_found.php cannot be found and will think that the redirected url is just being redirected.
Example:
<?php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
include("notFound.php");
?>
EDIT: If you are using this in the event of a file not existing on the actual server you will need to rewrite.
I am trying to use a htaccess file on my localhost in order to create user-friendly URLs. But I've not gotten a happy ending so far: I can't make it work properly. Here are the details:
I have the Apache running on Windows. My localhost is here: C:\AppServ\www\, so I accede to my local site ("university") through the next path with the browser: localhost/university
I have this url:
localhost/university/university.php?filter=private
And I want to be read simply like this:
localhost/university/university/private
So, I write the next code into my htaccess file (the file is into this folder C:\AppServ\www\university)
RewriteEngine On
RewriteRule ^university/private$ university.php?filter=private
That doesn't work. That opens university.php without any style. (In fact, when I have no htaccess file, if I try to accede to localhost/university/university/private, I have no 404 error; I have the same university.php without any style instead.)
But I have success when I write the next rule:
RewriteRule ^private$ university/university.php?filter=private
This work fine to localhost/university/private but not to localhost/university/university/private
I have no clue about where is the problem. Do you have one?
Thank you so much!!
That opens university.php without any style.
This is probably because you have relative URI's to access your style sheets, and the extra path node (/private) is making the browser think the styles are in the private folder, which doesn't exist. Try adding a relative URI base to the header of your page:
<base href="/university/" />
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.