OK, I need to upgrade to Drupal 6.0 but need to set up my localhost testsite first of all to be a copy of the live site.

I have managed to set up everything correctly and install the db etc. The homepage comes up perfectly, however, if i click on any of the links they bring up "404 The requested URL /xxx was not found on this server.' This is when the base url is set as : $base_url = 'http://localhost';

If I change the base url to be $base_url = 'http://localhost/drupal'; then all of the links go back to the wamp localhost page.

Can someone please help me as this is driving me mad. I know it is something small but dont know what i need to do to fix it.

The steps i took to set the site up were as follows:

Step 1 – Set up site locally
Currently using drupal 5.1
Downloaded 5.15 to desktop
Installed wamp server

Copied the drupal folder to c:/wamp/www/ and renamed it to ‘drupal’

Went to phpmyadmin and created a database called ‘drupal’

Went to privileges and created a new user:
• User name: xxxx
• Host: Local
• Password: xxxx
• No global privileges
Went to http://localhost/drupal and managed to access the drupal site on localhost : http://localhost/drupal/

Step 2 – Import Database

Went to phpmyadmin and imported the latest cut of the database

Step 3 – Copy files

I copied all of my files from the live server to the local environment
Then I went to the default/settings.php file and changed:

$db_url = mysql://xxxx:xxxx@localhost/drupal';

Changed: $base_url = 'http://localhost/drupal'; // NO trailing slash!

Comments

mdixoncm’s picture

It sounds like you are creating a local mirror of an existing site on your local machine, rather than a fresh drupal install?

The problem will be clean URLs, normally Drupal will run a check to make sure that clean URLs can be used before allowing you to turn them on - BUT - because you have imported a database you have bypassed this check and have clean URLs enabled on an environment that can't support them.

Easily fixed though - 2 options.

1. Turn off clean URLs - go to http://localhost/drupal/index.php?q=admin/settings/clean-urls

2. Enable modrewrite - if your using WAMP this should be as simple as editing your php.ini file, uncommenting the modrewrite line in the extensions section (just do a search for rewrite and you should find it), and then restart apache.

I would go with option 2 :)

Mike,
Computerminds offer Drupal development, consulting and training

The Snuffman’s picture

Hi Mike,

Thanks for the tip, however,...

#1 - says "You do not currently have the privileges required to access this page."

#2 - I went to the php.ini file and all i could find was :
"The URL rewriter will look for URLs in a defined set of HTML tags.
form/fieldset are special; if you include them here, the rewriter will
add a hidden field with the info which is otherwise appended
to URLs. If you want XHTML conformity, remove the form entry.
Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

That doesnt look correct to me. Any ideas?

thanks
Martin

www.snufftobacco.co.uk
There's snuffin' like it!

The Snuffman’s picture

Not to worry - I managed to find the login page and switch this off, so now all the links work.
The only issue now is that the site is not pulling in the css, once this is fixed then all is sorted.

BTW Mike, you started me on Drupal when you came into Openworld a couple of years ago!

cheers
Martin

www.snufftobacco.co.uk
There's snuffin' like it!

dman’s picture

Correction - mod_rewrite is enabled in the apache configs, not the php.ini.
Not sure exactly which file on a mamp distro, start with httpd.conf or apache2.conf (if neither exist, keep looking)

.dan.
if you are asking a question you think should be documented, please provide a link to the handbook where you think the answer should be found.
| http://www.coders.co.nz/ |

nig’s picture

I'm getting the same problem as this, even after enabling mod_rewrite.

I have set $base_url = 'http://local/headingleyorg';

Symptoms =
- homepage is fine on the local server, from my local files and database. It must be reading the CSS as well as the layout is good.
- no links on the homepage work. They all get 404 and "Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.5 with Suhosin-Patch Server at local Port 80"
- some links are wanting to connect to http://local/headingleyorg/node/3084 (which is what I'd expect) and some links are wanting to connect to http://local/node/3085 (which must be wrong as the headingleyorg directory is missing). But none of the links connect: they all get 404.

When I do
ls /etc/apache2/mods-enabled/
I can see rewrite.load in the list of enabled modules for apache2.

What should I try next?

Many thanks
Nigel
www.headingley.org

dman’s picture

Confirm that you've done everything described In the docs.

Simply, on a fresh install, Drupal should not even be trying/able to use clean URLs until it had confirmed that they worked. It only happens after it tests the ability internally. (Or you migrated a site without turning off clean URLs first)

In general you could/should be able to operate without needing to set $base_url. It's very hard to get Drupal to emit some URLs with and some without a site prefix - unless you have hard-coded said links into the theme or content somewhere (which is possible, and not rare, but a clear sign of non-drupal-think).

If you can get to /headingleyorg/?q=admin but not /headingleyorg/admin then your clean URLs are still not active. visit /headingleyorg/?q=admin/settings/clean-urls and turn them off. Any remaining problems are from your content, theme or build.

.dan.

EDIT: Yes, as I thought. Looking at http://www.headingley.org/ (which I guess is your target you are mirroring) the MENU items are generated by Drupal and should be respecting $base_url. The EMBEDDED links (in the user blocks and page content) are hard-coded to the webroot. This is separate from any clean_url issue. It's a portability thing which affects any website.
Tricky, and rather than fix that all over, you should look at using a virtualhost or a port number to run your local copy on. Both will allow you to continue to use the webroot-relative links.
pathologic.module may also help repair some of this. I can't recall.

nig’s picture

Thank you for this and for taking the time to look at my site. Following your post I have -
1. disabled clean urls on the live site at www.headingley.org
2. taken a backup sql.gz
3. restored the backup to my local server
The result is as you predicted. The links in Drupal menus work fine. The links I have manually added in pages and in user blocks still return 404 errors.

You say this is down to how I have "hard coded to the web root". Please will you explain more?
An example link I have used, in a page is,
<a href="/node/1679">click here</a>
This is the pattern I have followed in all my links, thinking I was doing the right thing. How should I code such a link?

I am keen to eradicate non-drupal think, but I don't yet know how to think the proper stuff!

Many thanks
Nigel

dman’s picture

The problem is that an URL beginning with / means 'top of the webserver' (web-root).
So shifting one website to another host does usually work.

Only you are shifting it to another directory also.
This is not your fault ... and' it's not Drupals either. It's just a thing about pathnames that it hasn't repaired for you.
I don't actually know any truly graceful fix for this. I've written plenty of ugly ones though.

Your best and most useful approach is (as I suggested) use a webserver on an alternative port or with an alternative hostname. Then you can continue to use /node/n links. Both are pretty easy to do on a local machine, and much less frustrating that trying to allow for a subdirectory.