1

aphdigital.org/GVH/ を gvh.aphdigital.org にリダイレクトし、aphdigital.org/GVH/something/ を gvh.aphdigital.org/something/ にリダイレクトしようとしていますが、かなり苦労しています。この質問のコードを試しましたが、機能しません。以下のコメントアウトされたコード ブロックも、リダイレクトで失敗した試みを示しています。私は何を間違っていますか?httpd.conf にアクセスできる場合はログを有効にしますが、FTP アクセスしかありません。構文エラーが原因で 500 エラーが発生しているように見えるため、apache がこのファイルを読み取っていることはわかっています。

ここに私の .htaccess ファイルがあります:

# Remember to enable display_errors on development environments only.
<IfModule mod_php5.c>
    php_value display_errors 1
    php_flag register_globals off
</IfModule>

RewriteEngine on

# If know that mod_rewrite is enabled, but you are still getting mod_rewrite errors,
# uncomment the line below and replace "/" with your base directory.
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/ - [C]
RewriteRule .* admin/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

# Added this on Jan. 4, 2013 to redirect from old URL to new. Doesn't seem to be working. 
RewriteCond %{HTTP_HOST} ^www.aphdigital.org/GVH$
RewriteCond %{HTTP_HOST} ^www\.aphdigital\.org/GVH$
RewriteRule ^gvh/(.*)$ http://gvh.aphdigital.org/$1 [L,QSA,R=301]
# End of Jan. 4 add.

#TEST for redirect added April 3. Also doesn't work. 
# To redirect /mysub/foo to http://mysub.mysite.co.uk/foo
#RewriteCond %{HTTP_HOST} ^(www\.)?(aphdigital\.org)$ [NC]
#RewriteRule ^(gvh)/?(.*)$ http://$1.%2/$2 [R=301,L,NC] 

#TEST2, code from Stackoverflow question 
#Options +FollowSymLinks -MultiViews
#RewriteEngine on
#RewriteBase /

# To redirect http:://www.mysite.co.uk/ to http:://mysite.co.uk/
#RewriteCond %{HTTP_HOST} ^www\.(aphdigital\.org)$ [NC]
#RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# To redirect /mysub/foo to http://mysub.mysite.co.uk/foo
#RewriteCond %{HTTP_HOST} ^(www\.)?(aphdigital\.org)$ [NC]
#RewriteRule ^(gvh)/?(.*)$ http://$1.%2/$2 [R=301,L,NC] 
#END TEST 2

#Intentionally breaking to see if reading .htaccess. Yep, this breaks it. 
#<directory / ></directory> 

<FilesMatch "\.(php|ini)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>

<Files index.php>
Allow from all
</Files>

# Uncomment the lines below in order to enable caching of some files via Apache (after a finished site has gone live)
<IfModule mod_expires.c>
#  <FilesMatch "\.(js|ico|gif|jpg|png|css)$">
#       ExpiresActive on
#       ExpiresDefault "access plus 10 day"
#   </FilesMatch>
</IfModule>

これは、Omeka CMS を実行しているサイト用です。

4

1 に答える 1

1

URL パスGVHは の一部ではない%{HTTP_HOST}ため、これは

RewriteCond %{HTTP_HOST} ^(?:www\.)?aphdigital\.org$
RewriteRule ^gvh/(.*)$ http://gvh.aphdigital.org/$1 [R,L,NC]

有効にしてテストしないでください。詳細について301は、この回答.htaccess 書き換えルールをデバッグするためのヒント を参照してください。

于 2013-04-03T22:36:33.543 に答える