从url路径中删除/ drupal

时间:2013-02-12 22:59:31

标签: drupal url-rewriting

我正在Drupal网站上工作,我希望将我的网站显示为www.ex.com而不是ex.com/drupal

我尝试过使用此代码:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^202.158.43.33$ [NC]

RewriteRule .* 202.158.43.33 [L,R=301]
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule .* drupal/index.php?q=$0 [QSA]
</IfModule>

保存在根文件夹中,我更改了$ base_url ='http://www.ex.com';在drupal / sites / default / settings.php

当我运行我的网站时,我将网址视为:202.158.43.33/202.158.43.33/202.158.43.33/202.158.43.33 .........

有人能告诉我如何解决这个问题。

2 个答案:

答案 0 :(得分:0)

使用Drupal的默认.htaccess文件,而不是编写自己的代码。然后取消注释这段代码的最后两行。

  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} !^www\. [NC]
  # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

虚拟主机文件配置:

<VirtualHost *:80>
    ServerAdmin me@mysite.com
    DocumentRoot "/var/www/http/mysite.com"
    ServerName mysite.com
    ServerAlias www.mysite.com
</VirtualHost>

文档根目录应该指向您在当前站点下导航到的Drupal,即“/ drupal”子目录。

答案 1 :(得分:0)

您是否需要将drupal文件放在此域中的单独文件夹中?我只是问,因为有一个明显的答案让一个人的drupal站点在根目录中运行:只需从drupal文件夹中移动所有文件(所有文件都位于&#34; drupal&#34;文件夹)到父(根)目录,您的网站将显示在www.yourdomain.com上,而不是www.yourdomain.com/drupal

相关问题