简体   繁体   English

Drupal localhost重定向到www.localhost.com

[英]Drupal localhost redirecting to www.localhost.com

I am working on a drupal site which I checked out (svn) to my localhost. 我正在一个drupal网站上工作,我检查了(svn)我的localhost。

Now the problem is that when I go to: 现在的问题是,当我去:

http://www.site.com http://www.site.com

it all works fine, but when I go to: 一切正常,但是当我去:

http://localhost/work/site HTTP://本地主机/工作/网站

I get redirected to 我被重定向到

http://www.localhost.com/work/site http://www.localhost.com/work/site

I have ran the install.php script and all works great. 我运行了install.php脚本,一切都很棒。 It reinstalls everything but when I go to the main site the redirect occurs. 它会重新安装所有内容,但是当我转到主站点时,会发生重定向。

I removed the .htaccess file, didn't do anything. 我删除了.htaccess文件,没有做任何事情。

I am using windows 7 ultimate 64 (also tried on winxp pro 32) apache 2.2, php 5.2.13 我使用的是Windows 7 ultimate 64(也尝试过winxp pro 32)apache 2.2,php 5.2.13

Anyone know anyway to fix this? 任何人都知道要解决这个问题?

Thanks 谢谢

The redirect is caused by Firefox not being able to get a good connection with the local server and then trying to "fix" the address. 重定向是由Firefox无法与本地服务器建立良好连接,然后尝试“修复”该地址引起的。 You can disable the behavior in Firefox as follows: 您可以按如下方式禁用Firefox中的行为:

  1. Type about:config in the address bar and hit return. 在地址栏中键入about:config并按回车键。
  2. Find browser.fixup.alternate.enabled. 找到browser.fixup.alternate.enabled。
  3. Double click the “true” value. 双击“true”值。 The line will become bold, and the value will change to “false” from here 该行将变为粗体,并且值将从此处更改为“false”

However that will not solve your underlying problem (local server isn't responding right), it will just get rid of really annoying behavior. 然而,这不会解决您的潜在问题(本地服务器没有正确响应),它将摆脱真正烦人的行为。 There are several possible causes of this failure, the host file problem MatW suggested is a common cause. 导致此故障的原因有多种,MatW建议的主机文件问题是常见原因。

In my case Drupal seems to be crashing Apache during certain page loads, which is hard to diagnose/fix when your browser keeps redirecting itself away from the page you need to refresh. 在我的情况下,Drupal似乎在某些页面加载期间崩溃Apache,当您的浏览器将自己重定向到您需要刷新的页面时很难诊断/修复。

Have you checked your window's hosts file? 你检查过窗口的主机文件了吗? Not sure about where it lives in Windows 7, but in XP it lives here: 不知道它在Windows 7中的位置,但在XP中它存在于:

C:\WINDOWS\system32\drivers\etc\hosts

Make sure there is an entry like this: 确保有这样的条目:

127.0.0.1       localhost

As a double-check, you may want to flush your PCs DNS cache. 作为仔细检查,您可能需要刷新PC DNS缓存。 Go into the command line and type: 进入命令行并输入:

ipconfig /flushdns

From the drupal sites/default/settings.php file: 从drupal sites / default / settings.php文件中:

/**
 * Base URL (optional).
 *
 * If you are experiencing issues with different site domains,
 * uncomment the Base URL statement below (remove the leading hash sign)
 * and fill in the absolute URL to your Drupal installation.
 *
 * You might also want to force users to use a given domain.
 * See the .htaccess file for more information.
 *
 * Examples:
 *   $base_url = 'http://www.example.com';
 *   $base_url = 'http://www.example.com:8888';
 *   $base_url = 'http://www.example.com/drupal';
 *   $base_url = 'https://www.example.com:8888/drupal';
 *
 * It is not allowed to have a trailing slash; Drupal will add it
 * for you.
 */
# $base_url = 'http://www.example.com';  // NO trailing slash!

Try setting $base_url = ' http://localhost/work/site '; 尝试设置$ base_url =' http:// localhost / work / site ';

I finally found the reason behind this huge problem. 我终于找到了这个巨大问题背后的原因。

It was the css and js optimization that was messing everything up. 正是css和js的优化让一切变得混乱。 I set those two to off and then copied the database to the localhost version of the site and all worked out great!!! 我将这两个设置为关闭然后将数据库复制到该站点的localhost版本,所有这些都很棒!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM