将所有URL重写为http://domain.com

将所有URL重写为http://domain.com

问题描述:

1) .htaccess 是否可以将您的所有URL重写为http://example.com?

1) Is it possible with .htaccess to rewrite all of your URLs to just http://example.com?

例如:

  • http://example.com/folder/subfolder/file.php-> http://example.com
  • http://example.com/index.php-> http://example.com
  • http://example.com/folder/file.php?foo=bar&baz=qux-> http://example.com
  • http://example.com/folder/subfolder/file.php -> http://example.com
  • http://example.com/index.php -> http://example.com
  • http://example.com/folder/file.php?foo=bar&baz=qux -> http://example.com

2)如果可能,这将如何影响SEO和页面排名?

2) If it is possible, how would this effect SEO and page rankings?

  1. 可以,请尝试以下规则:

  1. Yes possible, try this rule:

RewriteEngine On
RewriteRule . /? [L,R=302]

  • 由于未使用规则301 SEO可能不会受到影响.

  • Since rule is not using 301 SEO may not be impacted.