2015-07-28 2 views
1

Я тянул свои волосы на этом. Я хочу перенаправить весь трафик на мой новый сайт.Как перенаправить весь трафик отдельно от определенных папок в htaccess?

Новый сайт - mysite.org для аргументов. Однако есть определенные страницы и правила и папки, которые я хочу перенаправить на новый сайт - если пользователь не посещает эти папки или правила - это должен быть общий перенаправление на мой сайт?

redirect 301/http://example.org 
redirect 301 /index.php http://example.org 
redirect 301 /index.html http://example.org 
redirect 301 /contact.php http://example.org/contact-us 
redirect 301 /store-locator/list.php http://example.org/store-locator 
redirect 301 /store-locator/ http://example.org/store-locator 
redirect 301 /about.php http://example.org/about-us 
redirect 301 /customer-care.php http://example.org/contact-us 
redirect 301 /hq-location.php http://example.org/store-locator 
redirect 301 /privacy.php http://example.org/privacy 
redirect 301 /terms.php http://example.org/terms 
redirect 301 /policy.php http://example.org/returns 

ответ

1

Вы бы лучше использовать RedirectMatch вместо Redirect поскольку RedirectMatch использует регулярное выражение и соответствует только совпавшие URI, тогда как Redirect спичек любой URI, начиная с шаблоном при условии, следовательно, ваш первый правило всегда будет выполнять решений все последующие правила неэффективные ,

RedirectMatch 301 ^/$ http://example.org 
RedirectMatch 301 ^/index\.(html|php)$ http://example.org 
RedirectMatch 301 ^/contact\.php$ http://example.org/contact-us 
RedirectMatch 301 ^/store-locator/list\.php$ http://example.org/store-locator 
RedirectMatch 301 ^/store-locator/?$ http://example.org/store-locator 
RedirectMatch 301 ^/about\.php$ http://example.org/about-us 
RedirectMatch 301 ^/customer-care\.php$ http://example.org/contact-us 
RedirectMatch 301 ^/hq-location\.php$ http://example.org/store-locator 
RedirectMatch 301 ^/privacy\.php$ http://example.org/privacy 
RedirectMatch 301 ^/terms\.php$ http://example.org/terms 
RedirectMatch 301 ^/policy\.php$ http://example.org/returns 

Обязательно проверьте его после очистки кеша браузера.

+0

Спасибо за ответ ../store-locator/не будет перенаправлять, но/store-locator будет - завершающая косая черта? – TheBlackBenzKid

+0

Вы должны проверить в Chrome dev тоже с отключенным кэшем. – anubhava

+1

Теперь это работает. – TheBlackBenzKid

Смежные вопросы