简体   繁体   中英

301 Redirect old to New domain also non-www to www redirect (including index.php )

I have recently shift my old website to new name (Both website content and Space are same)

I want this 6 Permutation combination to happen due duplicate content policy of google :

  1. quantumeducation.in to http://www.quantum.edu.in
  2. www.quantumeducation.in to www.quantum.edu.in
  3. quantumeducation/index.php to www.quantum.edu.in
  4. www.quantumeducation.in/index.php to www.quantum.edu.in Also
  5. quantum.edu.in to to www.quantum.edu.in
  6. www.quantum.edu.in/index.php to www.quantum.edu.in

Currently im using this:

RewriteEngine on RewriteCond %{HTTP_HOST} ^quantumeducation.in$ [OR]

RewriteCond %{HTTP_HOST} ^www.quantumeducation.in$

RewriteRule ^/?$ "http\\://www.quantum.edu.in/" [R=301,L]

But It can't solve Step 4, 5 & 6

Any ideas why this wouldn't work ?

You can do this with a single regex in your rewrite condition:

RewriteCond %{HTTP_HOST} ^(w{3}\.)?(quantumeducation\.in|quantum.edu.in)$

You shouldn't need to change the PHP files if the server-level redirect is working properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM