简体   繁体   中英

.htaccess 301 redirect for domain root level

I have written a php website, and used 301 redirects to redirect old urls in old website to new urls in new website.

The general presentation of the 301 redirect is like this:-

RewriteRule     ^chs/hong-kong/brand.php$   /cn/our-company? [L,R=301]

Even though there are more than 100 such rules, they works perfectly well.

In Google Analytics, when visitors visits a particular page I can observe the new urls in the statistics figures, except for root level of the domain "/" . In users' URL, no matter they use http://sample.com , or http://sample.com/ , Google Analytics will not show "/" , but show "/hello.php" , while hello.php is not present in the new website, ie, no such file.

After some research work, I found hello.php was the landing page of the old website.

I would like to understand, how I can rectify the /hello.php in Google Analytics. One of the possible way I can think of is, to create another 301 redirect like this:

RewriteRule     ^hello.php$ /en/home? [L,R=301]

Interestingly, the redirect works in the URL, but again, Google Analytics still show /hello.php

Would there be other better solutions?

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