Skip to content

Commit 53ad356

Browse files
authored
Update shorturl-redirect.php
Quick Bugfix für Erstellung der .htaccess - #151
1 parent 0f08676 commit 53ad356

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Server/shorturl-redirect.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,17 @@ private function get_rules()
304304

305305
// Generate RewriteRules
306306
foreach ($short_urls as $url) {
307-
$short_url_path = trim(wp_parse_url($url['shorturl_generated'], PHP_URL_PATH), '/');
308-
$long_url = $url['long_url'];
309-
310-
$ret .= "RewriteRule ^$short_url_path$ $long_url [R=303,L,NE]\n";
311-
312307
if (!empty($url['shorturl_custom'])){
313-
$short_url_path = trim(wp_parse_url($url['shorturl_custom'], PHP_URL_PATH), '/');
314-
$long_url = $url['long_url'];
315-
316-
$ret .= "RewriteRule ^$short_url_path$ $long_url [R=303,L,NE]\n";
308+
$parsedUrl = parse_url($url['shorturl_custom']);
309+
$short_url_path = trim($parsedUrl['path']);
310+
$long_url = $url['long_url'];
311+
if (empty($short_url_path)) {
312+
continue;
313+
}
314+
315+
$ret .= "RewriteRule ^$short_url_path$ $long_url [R=303,L,NE]\n";
317316
}
317+
318318
}
319319
} catch (Exception $e) {
320320
echo "Error: " . $e->getMessage();
@@ -392,4 +392,4 @@ private function updateHtaccess(): void
392392
$shortURLRedirect->handleRequest();
393393
exit;
394394

395-
?>
395+
?>

0 commit comments

Comments
 (0)