Связаться
+79263772075
info@el-komp.ru

Blog

Слеш после рубрик WordPress + удаление множественных ///

Удаление слешей после html и множественных слешей

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^(.+\.html)/$ https://%{https_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Добавление / к рубрикам

либо вставка в function.php

function pcl_smart_trailingslashit($string) {
	/* ensure, that there is one trailing slash */
	$string = rtrim($string, '/') . '/';
	/* if there is a filename extension like .html or .php, then remove the trailing slash */
	if ( 0 < preg_match("#\.[^/]+/$#", $string) ) {
		$string = rtrim($string, '/');
	}
	return $string;
}
add_filter('user_trailingslashit', 'pcl_smart_trailingslashit');

 

Либо плагином

smart-trailing-slash

 

Иногда не хватает этих настроек и главная все равно с //// на конце

Просто добавляем

RewriteCond %{THE_REQUEST} //

RewriteRule .* /$0 [R=301,L]

 

Полезные ссылки

https://qna.habr.com/q/232562

https://searchengines.guru/showthread.php?t=1018269&page=10

 

Leave a comment

Ваш адрес email не будет опубликован.

четыре × 3 =

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Top Яндекс.Метрика