Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions includes/modules/redirections/class-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function export() {
* @return string
*/
private function apache( $items ) {
$output[] = '<IfModule mod_rewrite.c>';
$output[] = '<IfModule mod_alias.c>';

foreach ( $items as $item ) {
$this->apache_item( $item, $output );
Expand All @@ -106,7 +106,6 @@ private function apache( $items ) {
* @param array $output Output array.
*/
private function apache_item( $item, &$output ) {
$target = '410' === $item['header_code'] ? '- [G]' : sprintf( '%s [R=%d,L]', $this->encode2nd( $item['url_to'] ), $item['header_code'] );
$sources = maybe_unserialize( $item['sources'] );

foreach ( $sources as $from ) {
Expand All @@ -118,7 +117,10 @@ private function apache_item( $item, &$output ) {
}

// Get rewrite string.
$output[] = sprintf( '%sRewriteRule %s %s', ( $this->is_valid_regex( $from ) ? '' : '# ' ), $this->get_comparison( $url, $from ), $target );
$header_code = $item['header_code'];
$redirect_from = $this->get_comparison( $from['pattern'], $from );
$valid_regex = ( $this->is_valid_regex( $from ) ? '' : '# ' );
$output[] = sprintf( '%sRedirectMatch %s %s %s', $valid_regex, $header_code, $redirect_from, $this->encode2nd( $item['url_to'] ) );
}
}

Expand Down