从包含网站的文件夹redirect

我有一个网站从这个URL到达:

http://www.mysite.com/cms/index.php 

从这个目录提供服务:

 public_html/cms/index.php 

在public_html我有这个.htaccess

 RewriteRule (.*) cms/$1 [L] 

这让我到这样的网站:

http://www.mysite.com/index.php

但是现在如果我引用“旧”地址,我想用redirect代码redirect到重写的地址。

例如:

 http://www.mysite.com/cms/?q=node/1 is redirected to... http://www.mysite.com/?q=node/1 

我怎样才能做到这一点?

编辑:也在Drupal(cms)提供的.htaccess文件,这是写。 我试过启用它,但似乎没有任何效果。

  # 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 

编辑:包括更多的.htaccess文件 – 似乎相关。

  # Block access to "hidden" directories whose names begin with a period. RewriteRule "(^|/)\." - [F] #Strip cms folder from url RewriteRule (.*) cms/$1 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] # Rules to correctly serve gzip compressed CSS and JS files. # Requires both mod_rewrite and mod_headers to be enabled. <IfModule mod_headers.c> # Serve gzip compressed CSS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.css $1\.css\.gz [QSA] # Serve gzip compressed JS files if they exist and the client accepts gzip. RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}\.gz -s RewriteRule ^(.*)\.js $1\.js\.gz [QSA] # Serve correct content types, and prevent mod_deflate double gzip. RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1] <FilesMatch "(\.js\.gz|\.css\.gz)$"> # Serve correct encoding type. Header append Content-Encoding gzip # Force proxies to cache gzipped & non-gzipped css/js files separately. Header append Vary Accept-Encoding </FilesMatch> 

使用redirect301,而不是mod_rewrite。

示例通过googlefu: http : //www.webweaver.nu/html-tips/web-redirection.shtml

编辑:或R = 301在您的重写标志。