Rewrite all URLs to http://domain.com

2019-09-19 10:26发布

问题:

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

E.g.:

  • 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) 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]
    
  2. Since rule is not using 301 SEO may not be impacted.