アップデート02
こんにちは、みんな、
After much searching I found a very good clue that helped me take some important steps towards my goal. Everything is now working well except for the following:
I need to ReWrite or ReDirect to www.domain.com/go404 in these cases:
www.domain.com
www.domain.com/
domain.com
domain.com/
But not, of course, when they type
www.domain.com/subdomain or
domain.com/subdomain
Presently, my htaccess code has this snippet added:
# This sends "just domain" visits to 404
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/go404 [R=301,L]
# This one makes a NON WWW become a WWW
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
# This strips the trailing slash
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
Can anyone tell me how to set up the condition so it ONLY allows domains written without the trailing slash and/or subfolder string? As indicated above those should redirect to 404.
ありがとう!
私の元の質問からの更新:
こんにちはみんな、私は提供された解決策を試しましたが、それはうまくいきません。要点をまとめると:
I'm trying to get our Magento site to respond as in the table below using .htaccess rewrites. For whatever reason, only some options work (marked as "Ok"). The others produce www.domain.com, that I don't want (marked as "Fail").
訪問者がタイプする場合(内部)結果は次のようになります:--------------------------- ------------ ------------------------- www.domain.com www.domain.com/go404(失敗)
www.domain.com/www.domain。 com / go404(失敗)
www.domain.com/notfound www.domain.com/go404(OK)www.domain.com/subdomain
www.domain.com/_subdomain(Ok)www.domain.com/subdomain/www
。 domain.com/_subdomain(Ok)www.domain.com/admin
www.domain.com/admin(Ok)
domain.com www.domain.com/go404 (Fail)
domain.com/ www.domain.com/go404 (Fail)
domain.com/notfound www.domain.com/go404 (Fail)
domain.com/subdomain www.domain.com/_subdomain (Fail)
domain.com/subdomain/ www.domain.com/_subdomain (Ok)
domain.com/admin www.domain.com/admin (Fail)
To keep things in order in our Root, all subdomains are folders called _subdomain. Visitors to the site only have to write www.domain.com/subdomain and we add the underscore in front.
注:「notfound」は、対応する「_subdomain」フォルダーのない文字列
です。「admin」は有効な例外です。前にアンダースコアがありません
上記の表からわかるように、「www」のないすべてのアドレスは失敗します。また、「クリーン」ドメインと末尾にスラッシュが付いたクリーンドメインに関連する2つの特定の問題があります。
これは私の完全なhtaccessです(コメントを消去して短くしました):
addhandler x-httpd-php5-cgi .php5
addhandler x-httpd-php5-cgi .php
addhandler x-httpd-php-cgi .php4
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_php5.c>
php_value memory_limit 256M
php_value max_execution_time 18000
php_flag magic_quotes_gpc off
php_flag session.auto_start off
php_flag suhosin.session.cryptua off
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
</IfModule>
<IfModule mod_ssl.c>
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
RewriteRule ^api/rest api.php?type=rest [QSA,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
AddDefaultCharset Off
<IfModule mod_expires.c>
ExpiresDefault "access plus 1 year"
</IfModule>
Order allow,deny
Allow from all
<Files RELEASE_NOTES.txt>
order allow,deny
deny from all
</Files>
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^domain\.com/(admin)$ www.domain.com/$1 [L]
RewriteRule ^/(.*)$ www.domain.com/_$1 [L]
RewriteRule ^www\.domain\.com/(admin)$ www.domain.com/$1 [L]
RewriteRule ^www\.domain\.com/(.*)$ www.domain.com/_$1
ありがとうございます
古い質問:
.htaccess rewritesを使用して、この方法でサイトに応答させようとしています。何らかの理由で、オプションの1つだけが機能し(「OK」とマーク)、他のすべてのオプションはwww.domain.com(「Fail」とマーク)を生成します。
私はこの組み合わせを達成する必要があります:
When visitor types The (internal) result should be:
----------------------------- --------------------------------
www.domain.com www.domain.com/go404 (Fail)
www.domain.com/ www.domain.com/go404 (Fail)
www.domain.com/subdomain www.domain.com/_subdomain (Ok)
www.domain.com/admin www.domain.com/admin (Ok)
domain.com www.domain.com/go404 (Fail)
domain.com/ www.domain.com/go404 (Fail)
domain.com/subdomain www.domain.com/_subdomain (Fail)
domain.com/admin www.domain.com/admin (Fail)
私の(ルート).htaccessファイルには次のものがあります:
RewriteRule ^/(admin) www.domain.com/$1
RewriteRule ^/(.*) www.domain.com/_$1 [L]
domain.comをwww.doman.comに強制的に入れてみました
RewriteRule ^domain.com$ www.domain.com (Fail)
ところで:サブドメインフォルダ(_subdomain)にも.htaccessファイルがあります。そこにもRewriteRuleを追加する必要がありますか?私は無駄に/なしで試しました。