404 error on drupal after migrating - drupal

I have a Drupal website in the internet.
I want to work on local from now, so I install Wamp, I copy-pasted the apache filesystem of the website and made a sql dump with phpmyadmin.
I re-create the same database on phpmyadmin with the same name & datas than on the web.
Now, I can access to the main page (the ). All is ok, i see a node, I see the whole menu with links, ...
When I try to navigate or log, it give me 404 error, what is wrong? URL sounds great, when I try ti access to anode with the nodeid, 404 again.
I suspect WAMP but I don't know how fix that problem!
Thanks a lot to help me!

Make sure mod_rewrite is enabled - it isn't enabled by default on WAMP.
You can find instructions on how to do so here.

Most likely you have AllowOverride set to None in Apache. I believe that is the default, and it will prevent your .htaccess files from working (These are the files that make your URLs work).
Edit your Apache config file, search for every instance of AllowOverride and change it to "All", E.g:
AllowOverride All
Also make sure you actually copied the .htaccess file down, sometimes it's hidden.

Make sure you have uploaded the .htaccess file to Drupal's root directory.
Or try to access your website with ?q=, like: http://site.com/?q=admin

Have you installed the local site in a sub folder? What's the local URL?
If the site is located in a subfolder, e.g. http://localhost/drupal, you'll need to add (or uncomment) a line in .htaccess that tells apache about the RewriteBase.

AllowOverride was set to None in my httpd.conf. Changing to AllowOverride All worked like a charm.
Remember to restart apache after the change.

Related

Updating failed Post in Wordpress

I am working on WordPress blog and just started to post a new post its giving error me "Updating failed". I am not able to edit the sample post and also not able to post a new article.
WordPress Version: 5.0.2
Any Idea to resolve this issue?
Thanks
Browser Inspector View
This problem is caused by the Gutenberg editor.
If you're website is hosted by any hosting provider, use the classic editor.
If you're hosting your website on a VPS, and you're running on Apache, try adding
<Directory /path/to/your/website>
AllowOverride All
</Directory>
To your virtual host.
If you want to get rid of this issue, you have to change the permalink structure from the admin side.
Please read this article Solution link
I saw the same problem occur when I would select certain Permalink settings (specifically ones that caused the site's .htaccess to contain anything other than a blank file).
The issue ended up being: I did not have mod-rewrite enabled on my server.
The fix: I uncommented the below (in httpd.conf) and the problem went away (and it stayed fixed no matter what Permalink settings I select in WordPress) (be sure to restart Apache after httpd.conf edits)
LoadModule rewrite_module modules/mod_rewrite.so
WordPress permalinks error for "pretty permalinks" on a Google Cloud instance gives 404 error on all the pages even if created using the default permalink, reverting it back to "pretty permalinks".
I like "pretty permalinks" and found out the best solution for the above situation is to
Enable mod_rewrite in Apache:
Then, goto
Compute Engine>VM Instances > SSH
Type $: a2enmod rewrite
Type $: sudo nano /etc/apache2/apache2.conf
then Change: AllowOverride ALL from AllowOverride NONE
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride ALL
Require all granted
</Directory>
Restart Apache Server:
sudo service apache2 restart
It should now update, create posts/pages in "pretty permalinks" with default Gutenberg editor without giving 404 error.
Solves the Rest API error
https://www.praj.info
My site was behind Cloudflare and this seemed to be the reason for this issue.
In order to fix it I just installed cloudflare plugin for wordpress.
This error occurs when you are working on the Gutenberg editor. You can use the classic editor to overcome this problem.
Go to the plugins>add new
Search for a classic editor plugin and install it.
If this doesn't work deactivate all plugins.
After, you disabled all plugins start enabling plugins one by one to see which one will break WordPress again.
Or you can see this article:- fix WordPress updating failed while creating or publishing a post.
Check the url in the wordpress setting, you probaly set website url as "http". It'll be fixed.

WordPress Permalinks Issue

So we installed a fresh version of WP. Thanks for the help earlier.
The last issue we cannot figure out is why we cannot navigate the site.
Basically, when we try to navigate internally into the website we imported into the sandbox, it gives the following:
The requested URL /page-name/ was not found on this server.
If it's the ugly / default Permalink, we can view the files under pages, but we cannot navigate even. The pages were set to /page-name/, which I'm pretty sure is /%postname%/. I've scoured online. I've put up a blank .htaccess file, changed the permissions to 666 for writing purposes.
What I've tried included:
Replacing the .htaccess with a blank (I renamed the old one to be a backup) - it generates information to the file.
We can view pages manually that way, but we cannot navigate through the "live" site with it running this way.
Is there a second source I should be referring to for updates on the .htaccess file? Is there tricks online I may have overlooked? Any input would be appreciated!
Thank you!
Thank you Milap for the comment above! It turned out to be the AllowOverride being false. Apparently this have to be enabled in order for it to work. To those who plan to make this change, restarting your server is required.
Please refer to section AllowOverride Not Enabled section of their documentation: https://codex.wordpress.org/Using_Permalinks

Wordpress Directory Switch Issues

I recently set up a digitalocean account with wordpress pre-installed. When it is pre-installed, the directory structure begins in the root (var/www/html/). I wanted to change this, so i moved the files into a new directory (/var/www/html/viralnewz) and changed the wp-config files to represent this (they no longer point to the http://178.62.87.202/ but instead to viralnewz.co.uk, which in turn will point to viral newz directory (/var/www/html/viralnewz). This is set up with a virtualhost, and works fine for the front-page and the admin. But when i try and view others pages, i get a 404 not found. I'm assuming theres an issue with the wordpress setup because it can't find the correct page, however i'm unclear how to actually solve this issue.
Apache conf file
<VirtualHost *:80>
DocumentRoot /var/www/html/viralNewz/
ServerName viralnewz.co.uk
# Other directives here
</VirtualHost>
Additionals to wp-config.php
define('WP_HOME','http://viralnewz.co.uk/');
define('WP_SITEURL','http://viralnewz.co.uk/');
If i've missed any other information that could be beneficial, please mention it and i'll do my best to find it.
Chris
I think your problem can be related to url values stored in DB.
You can migrate safely using this tool, that permit to find and replace the urls stored in DB.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Can be also necessary update .htacess file: normally is enough enter in permalink settings and save again the structure of permalinks.

Wordpress permalinks broken

I have recently moved my blog from one serever to another. I am now unable to restore my permalink structure.
Now my permalink strucure has become /?p=123. Whenever, I try to change it to any other custom permalink structure, it throws 404 for all the posts. Check the blog at http://microreviews.org
I have been forced to make the permalink structure as /?p=123. All the entries from search engines are however on the old structure /%postname%/
None of the plugins for the same seem to work and I am stuck with the ?p=123 structure.
What should I do?
Assuming you're on Apache server:
You don't have the .htaccess file on the new server, or
the new server doesn't have mod_rewrite turned on, or
the new server ignores the .htaccess files, or
any combination of the above :)
The other option instead of using .htaccess (although Wordpress is built around modifying that file) you can take the contents of the .htaccess file and add them to a directive in your httpd.conf (or virtual host config file). This approach requires more access to your apache installation (i.e. it might not work with some hosting solutions), but according to the Apache httpd documentation it's more secure and less work on the server since apache will scan every directory for .htaccess files each time a page is accessed and it will re-load the .htaccess file(s) every time the page is accessed as well. If the access is put into the server config then it is loaded once at apache start-up (or on a server reload) and that's it.
For example:
If your .htaccess file contained the following for the /www/htdocs/example directory
AddType text/example .exm
Then the following in your httpd.conf file would be equivalent
<Directory /www/htdocs/example>
AddType text/example .exm
</Directory>
The approach of editing your main configuration instead of .htaccess does not require that you specify AllowOverride to something other than None.
In this case, you'll still need mod_rewrite enabled for permalinks to work correctly.

WordPress 404 Errors

I moved a Wordpress website from one server to another and I am now getting 404 errors on everything but the home page.
I also checked that the .htaccess file is there and the database contents. They are fine. Not sure what else could be causing this.
Any ideas from the community?
Assuming you have pretty permalinks enabled, are you sure that the new server has mod-rewrite enabled? You can also check to see if this is the problem by going to a pagelike yoursite.com/?p=1 where 1 is a page id.
Assuming the URL has changed
You need to update either the database or (if you're lucky) one of the .php files in the wordpress distro - see the wordpress article on this.
I had the same issue and ended up having to edit the database. You're seeing the 404's because wordpress thinks it's still hosted at the old URL and is therefore trying to retrieve files from it.
If the URL has not changed
Perhaps permissions need updating on the folders? The folders should be set at 755 and the files 644 (reference here).
Looks like you may have solved the problem - I had a similar problem where permalinks would not work, but the default links did work. I modified the .htaccess file to what Wordpress said to do. Twice I thought I had solved the problem, but didn't.
I had moved it to my local Ubuntu Karmic Koala system for testing, and found that the solution involved editing a file in /etc/apache2/sites-enabled. On my system, it was called 000-default.
This file had statements like the .htaccess file, and in two places had AllowOverride None, which I had to change to AllowOverride All. Apparently, this file overrides any local .htaccess files.
I also had to change the location of Wordpress in the main configuration, but that was obvious.
I hope this will help someone who has tried all the normal suggestions like me, and is still having problems.

Resources