301目录URL及其所有内容到另一个不包括子目录

时间:2013-12-27 17:47:25

标签: http-status-code-301 post-redirect-get

我在“/ Video /”目录中有一个wordpress网站,在子目录/ Video / Play /中有另一个PHPMELODY视频脚本。 在这种情况下,我想将名为“视频”的目录中的所有网址重定向到“播放/ /”除了/Video/Play/index.html。
  我真的需要帮助,谢谢!

** * *** 让我说清楚 * ** * ** * **
www.mysite.com/Video/--------- wordpress网站

www.mysite.com/Video/Play/---- PhpMelody网站*

我希望“视频”文件夹中的所有网址都被重定向到“播放”文件夹中,如www.mysite.com/Video/Play/index.html或www.mysite.com的index.php。 只需从重定向中清除目录(文件夹)“播放”。

*********************

#BEGIN mod_gzip-Turn on compression
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
# END mod_gzip


 # BEGIN Expire cach headers
<ifModule mod_expires.c>
 ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
 ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
# END Expirecach  headers


 #BEGIN Cache-Control

 <ifModule mod_headers.c>
  <filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
  Header set Cache-Control "max-age=2592000, public"
 </filesMatch>
 <filesMatch "\\.(css)$">
 Header set Cache-Control "max-age=604800, public"
</filesMatch>
 <filesMatch "\\.(js)$">
 Header set Cache-Control "max-age=216000, private"
 </filesMatch>
 <filesMatch "\\.(xml|txt)$">
 Header set Cache-Control "max-age=216000, public, must-revalidate"
 </filesMatch>
 <filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
#END Cache-Control

#301 redirect URL Canonication
RewriteEngine On
RewriteCond %{HTTP_HOST} ^ephremtube\.com
RewriteRule ^(.*)$ http://www.ephremtube.com/$1 [R=permanent,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
 RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
 # Mobile redirection
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-  
 mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
 RewriteRule ^$ http://www.ephremtube.com/m/ [L,R=302]
 </IfModule>
 #BEGIN  pass the default character set
 # END  pass the default character set

1 个答案:

答案 0 :(得分:0)

RewriteEngine On
RewriteCond  %{REQUEST_URI}  ^/Video  [NC]
RewriteCond  %{REQUEST_URI}  !^/Video/Play  [NC]
RewriteRule  ^Video/?(.*)$  /Video/Play/index.html  [R=301,L]
如果我理解你的要求,

可以工作。它将处理以/ Video AND开头的任何URI,而不是以/ Video / Play开头。