How to solve the other 404 errors on the home page after the Drupal site is changed to server-PHP source code

Source: Internet
Author: User
Tags drupal
After the Drupal site is changed to the server, except for the other 404 errors on the homepage, how can we solve the problem that the site space previously created for the customer is about to expire? at that time, I bought an American space that can only store one site separately, later, I switched to another big-point vm. The site was made of Drupal, but it was normal to open the home page after I switched to the new host. However, when I clicked on the inner page, I found it was. the htaccess file is not uploaded.

Problem description:

"Page not found" Errors on every page should T homepage ."

That is to say, the drupal website you created can be accessed on the homepage, and all other sections are accessed and displayed as the 404 error page.

Problem analysis:

This problem is most likely caused by the mod_rewrite module on the new server or the incorrect configuration (or drupal pseudo-static) of the clean URLs ). We typed a http://www.example.com/index.php in the address bar? Q = user: Check whether the mod_rewrite module works properly. the check method is as follows:

If the login page appears after you enter the preceding address, we can assume that the php virtual host server of the drupal site is okay, but the mod_rewrite module is not enabled. To determine whether the mod_rewrite module is enabled, we can create a file named phpinfo. php for the php probe of your website installation environment, and add the following code to this php file:
Phpinfo ();
?>

Save the file, upload it to the root directory of the drupal site on the php VM using FTP, and then use your website domain name/phpinf. php to execute, you can see the environment configuration of your space.

Make sure mod_rewrite is enabled.

In the address bar, enter http://www.example.com/phpinfo.php?#loaded Module (loading Module) to check whether mod_write is included. If it is not included, it means that the apache server does not load this module, let alone enable it. The created phpinfo. php file is retained. we will use it in the following introduction.

Confirm that the. htaccess file is working properly

There is a. htaccess file under the root directory of the drupal site. First, we use FTP to log on to the root directory of the php virtual host, find this file, and download it to a local backup. Create a new. htaccess file and add the following expression to it:
DirectoryIndex phpinfo. php

Save, and then use FTP to upload and overwrite the. htaccess file under the root directory of the drupal site. Then enter the http://www.example.com in your browser (the address of your drupal site), if you jump to phpinfo. php, it means that the. htaccess file under your site is working properly.

Tip: after confirmation, remember to restore the backed up. htaccess file to the. htaccess file on the existing site.

Carefully confirm rewrite_base configuration

After confirming that the. htaccess file is working properly, let's confirm the configuration of "RewriteBase" and "RewriteEngine" in the. htaccess file. (See: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html for details)

The. htaccess rewrite function is enabled successfully.

If phpinfo. php is not displayed, locate the configuration file of the apache server and start the. htaccess rewrite function. The file location varies with the server platform. For example, on the Ubuntu Server, the VM configuration file is in/etc/apache2/sites-enabled/000-default. By configuring mod_rewrite in. htaccess, apache configuration must allow the lowest file access control permission. to make this simple directory index test work, the apache server must allow "index" rewriting. In the server configuration file, we can find the following two lines:




Do not add or edit rewrite commands in the middle of this block, which may cause security risks. For more information, see the official document:

Http://httpd.apache.org/docs/1.3/mod/core.html#allowoverride

All override allowed:

AllowOverride All


Only rewrite:

AllowOverride Indexes Options FileInfo


Now, the apache configuration is Reloaded. this is also because of the platform. on the Ubuntu platform, the command is as follows:
1 #/etc/init. d/apache2 reload

Enter the domain name of your website in the browser, and the configuration information of the php Server will be displayed. if so, the php Server can be accessed normally after modification. When your simple link (Clean URLs) does not work properly, you must start with "successfully enabling the. htaccess rewrite function.

Drupal official technical documentation original: http://drupal.org/node/228462

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.