Main page (homepage) works fine, all others give 404 error

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
drn1111's picture

Ok, so I decided to move hosting providers. I transferred all of the content, I transferred all of the databases, I edited all the configs for the databases so that they would see and login to the new MySQL location. When I go to the website the main page pulls up fine, however, if I try going to ANY other pages (unless it is a direct link to an add-on website), or even logging in for that matter I get a 404 Page not found page...and it's not the custom when I have setup in Drupal.

Take a look around the new host, you get 404 errors on almost everything you click on unless it is a named link back to the old host.
Please help me people, I have absolutely no idea how to fix this issue. If you have any questions please reply here and I will answer them as quickly as possible.
Thanks a million in advance!

Comments

Clean URLs

JCL324's picture

Sounds like the new server is not setup to do clean URLs. You'll have to check with the hosting co. to figure out how that's done.

JCL

check .htaccess file

greta_drupal's picture

Check your .htaccess file. Upload, or copy/paste, this one:

Missing .htaccess file in the drupal root

ThirstySix's picture

Missing .htaccess file in the drupal root. Once copy & paste it works.

Check .htaccess file

greta_drupal's picture

Edit the .htaccess file in your Drupal root folder. Maybe issue with the symlinks. Try to copy/paste the below, and see if that resolves (it has worked for me in the past for same issue):

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch ".(engine|inc|info|install|module|profile|test|po|sh|.sql|theme|tpl(.php)?|xtmpl|svn-base)$|^(code-style.pl|Entries.|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example.com$ [NC]
  # RewriteRule ^(.)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
  # RewriteRule ^(.
)$ http://example.com/$1 [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

good tank`s

saeid.ahmady's picture

good
tank`s

Helpful

sadamafridi's picture

Perfect, thank you

You may not even have copied

bhosmer's picture

You may not even have copied your .htaccess from your other site. I had this same issue and pulled my hair out until I figured out this was the culprit. Usually on your local machine, it is a hidden file and you don't even know it is there.

That did it for me as well..

RoTalk's picture

I was surprised that I migrated a site and forgot to include the .htaccess which freaked me a out at first trying to figure it out. Just copied the file from another directory/site hosted on the same server.

Sounds like classic missing

StuddMan's picture

Sounds like classic missing .htaccess file

"Almost everything"

verta's picture

I agree somewhat more with the first post since this did happen to me a couple of times.

Have you tried links with and without the "?q=" yet? If you have links that assume clean urls is working, but it's really not, you'll have trouble with them. Try yoursite.com?q=admin/settings/clean-urls and turn them off. You may have to recode your hyperlinks that used the clean urls, they won't work when it's turned off.

That way you can debug why clean urls aren't working but your site will still work while you work on it.

Thanks to everyone

drn1111's picture

Thanks to everyone to help me with this issue. The .htaccess file is missing and now is working only some time and some time take long time to load any page 20-30 min and browser tell me too long to upload. I don't know what is wrong with this site. Work for two month and stop working. I can't login now. Please any help will be very greatly appreciated.

http://www.orlandoairporttaxi.info/orlando2/

Thanks a million in advance!

can you get into the site logs

verta's picture

My guess is that something is up with your web server. See if you can read your web server logs, your back end administration login should have a place where you can get to your site's logs.

The .htaccess file might look like it's missing because it is hidden. The dot means it is "hidden" so be sure you have set whatever you are using to look at the files to show hidden files.

Try using FTP or the administration pages file transfer to put the file on your site.

My other thought is that it looks like you have put your new Drupal site into a sub folder of your existing site, perhaps others looking at this will spot something about that, especially .htaccess related.

You might want to register a different domain name for testing the new site, make a new folder on your hosting account for it, and put your site in the root of that folder.

also check your PHP error logs

verta's picture

I can't get to the login screen on your site using ?q=user either, so there's something going on that you're probably not going to figure out without reading the apache and php error logs. You should contact your hosting provider if you don't know where the logs are.

It could be something as simple as permissions on the folder, make sure the web server has sufficient permission. You'll see permission errors in the logs if that's what is going on.

PPHP error lods

drn1111's picture

php error logs is not working and go daddy techincal suport tell me is not go daddy problem host account is working.

THANK YOU!!!

drn1111's picture

change the host to Bluehost and the site working no problem go daddy is the worst host ever and NO customer support

http://www.orangetrans.com/

Thank you!!

mandermonkey's picture

I wish I would have began looking for this post a few hours ago! But thank you for your help, you saved me many hours of work!

.htaccess and settings.php

chen.730's picture

For me, I got help from my host company support. (The clean URL doesn't seem to be the cause of the problem.) They suggested that the issue is only present when you try to access your site with the temporary url and would NOT be present when the domain is pointing at the right DNS. So you could:

  1. Change a system file (a file called "hosts") on your computer to make your browser thinks the temp url is the right one: http://www.inmotionhosting.com/support/website/drupal/how-to-create-a-me...

  2. Or change settings on your site. Two files:
    a) .../sites/default/settings.php
    Set the $base_url and un-comment it.
    $base_url = 'http://yourtempurl.com/directory';
    and
    b) .htaccess:
    Set the RewriteBase and un-comment it.
    RewriteBase /directorytoyoursite

The 2nd method worked for me.

RewriteBase solved it for me

millionleaves's picture

I just moved a site to a Bluehost VPS. The front page would load fine, the internal pages generated an error.

I changed RewriteBase to:

RewriteBase /

and it worked.

@chen.730 - thanks for your suggestion.

IT WORKED!

manuel.solis's picture

Thank you!! Thank you very much!

b) .htaccess: Set the

matiaslezin's picture

b) .htaccess:
Set the RewriteBase and un-comment it.
RewriteBase /directorytoyoursite

It did the trick for me, thanks!

.htaccess file issues

redearthbluesky's picture

Hello, same problem. Xampp error logs showed I was in a loop when clicking links, the homepage loaded fine but no access to admin either. A co-worker came up with the following solution in .htaccess;

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

.htaccess file issues

ferenju's picture

Hi,
One solution that can help you is disabling clean url check box in your old drupal admin/config section, before you move any files to the new server location

Here are the steps
OLD SERVER
1. disable clean url (in drupal admin)
2. Set your theme to one of drupal's core theme,
3. clear catch
4. FTP, or zip your drupal files and DB from old server and transfer them to the new server.

NEW SERVER
5. Create DB on the new server with user privileges and import the old DB
6. import all old files and extract.
7. change permission for folder site/default from 0555 to 0755
8. update the DB connection on site/default/setting.php
9. change permission for site/default BACK to 0555.

That is all !!!
check your site hope it will work.

AD

.htaccess file issue

Nitishkumar's picture

This was missing .htaccess file. It worked for me after adding .htaccess file

Thank for your comment

lxbon's picture

I'm facing this problem for my website dich vu viet luan van. I'm trying to solve this

Hi so I have the same issue

aiirtime's picture

Hi so I have the same issue and I try everything in this listings but it doesn't helped.
I also try out the drupal step by step to check rewrite mod and apache rewrite communication and the only site which i can see is my entrysite and the phpinfo site if I force it by the browser to open the file included in the directory.
Also if I uncomment rewrite config lines in .htacces and site.conf it still doesn't change anything.
Also I start from the scratch and it still the same.
So I have a server and full access to them what can I try to fix this?
For me it looks like the links doesn't work like they should, but why?
best air

What do the hrefs show as in

DigitalFrontiersMedia's picture

What do the hrefs show as in your links? If it's not .htaccess, maybe you need to set $base_url in settings.php?

Hi, I try to answer, but all

aiirtime's picture

Hi,
I try to answer, but all time I'm block.
Don't know why?
best air

I try to write my findings

aiirtime's picture

I try to write my findings but all time I'm block sry.
If I add at the browser index.php between my base_url and the drupal link then it works. Sorry for short description

Ok, I hope it works this

aiirtime's picture

Ok,
I hope it works this time.
I only found $file_public_base_url which is uncomment.
I set a $base_url at the end, but this doesn't helped.
So I didn't restart or else because it is a php setting was this right?

But I found something out:

Sounds like you're using

DigitalFrontiersMedia's picture

Sounds like you're using Drupal 8 and that it's either an .htaccess issue or server configuration issue. Follow the guidelines here and you'll probably get it sorted:
https://www.drupal.org/docs/8/clean-urls-in-drupal-8/fix-drupal-8-clean-urls-problems

CLEAN URLs

GmanBB's picture

I had same problem on GoDaddy. Only solution was go go on localhost and copy path to clean URL setting:
http://localhost/?q=admin/config/search/clean-urls

Settings on other files did not helped.

Thanks for all who helped to find the answer.

CLEAN URLs

GmanBB's picture

I had same problem on GoDaddy. Only solution was go go on localhost and copy path to clean URL setting:
http://localhost/?q=admin/config/search/clean-urls

Settings on other files did not helped.

Thanks for all who helped to find the answer.

CLEAN URLs

GmanBB's picture

I had same problem on GoDaddy. Only solution was go go on localhost and copy path to clean URL setting:
http://yoursite.com/?q=admin/config/search/clean-urls

Settings on other files did not helped.

Thanks for all who helped to find the answer.

Go to the file using

Vignesh soundararajan's picture

Go to the file using http://www.example.com/phpinfo.php

Check for a section called Loaded Modules. and check if mod_rewrite is enabled .
If Not enabled Linux run command sudo a2enmod rewrite .
Then restart server systemctl restart apache2 .

mattstein's picture

Recently my downloaded sites that I run on Acquia's DevDesktop v2 stopped working. With the help of the earlier responses on this page and the excellent page about CLEAN URLS posted on drupal.org (https://www.drupal.org/node/15365) I was able to add the missing line from the DevDesktop-generated httpd.conf (apache settings).
Based on my experience it seems that DevDesktop is not including the mod_rewrite Apache module and its activation line ("Load ..") in the Apache configuration file. So if you are running a Drupal site on DevDesktop and the homepage loads but none of the links work -- it is probably this issue.

Server configuration for Clean URLs on a dedicated server, with httpd.conf
Enabling clean URLs on a dedicated server involves these steps:
1. Enable mod_rewrite for Apache.
At a minimum, this will involve making sure that mod_rewrite is enabled for your installation of Apache.
To test if mod_rewrite is available in Apache2, you can type the following at a command prompt, to list all installed Apache modules:
apachectl -M

If the rewrite module is not in the list, it will have to be either compiled-in or made available as a loadable module. Generally speaking, you can tell Apache to load the module by including:
LoadModule rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c
in your Apache configuration file (see below for information on the configuration file).
(This line was missing from my httpd.conf file auto-generated by DevDesktop).

2. Restart apache
apachectl -k restart

Hope that helps someone.

Thank you so much!

GmanBB's picture

Same issue, fife by creating .htaccess file and add content to it.
Thanks a billion!

Gman

Make sure your 000-default.conf is configured properly

jasom's picture

Also make sure your /etc/apache2/sites-enabled/000-default.conf is configured properly. There should be

        <Directory /var/www/html>
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

placed right before </VirtualHost> ending. This was winning configuration on Ubuntu 18.04 and Apache 2.4.29 + Activating all mods required by root .htaccess.

See https://dzone.com/articles/install-drupal-on-ubuntu-1804

Florida

Group organizers

Group categories

Florida Topics

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week