Skip to content

Instantly share code, notes, and snippets.

@elias1435
Last active March 13, 2024 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elias1435/c2cf71442fd923dd6d39f78003a1a1bf to your computer and use it in GitHub Desktop.
Save elias1435/c2cf71442fd923dd6d39f78003a1a1bf to your computer and use it in GitHub Desktop.
Sometime we need to redirect a url directory. Use this index file to redirect the visitors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0;url=https://www.exmaple1.com/pages/details/">
<title>Redirecting...</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="https://www.exmaple.com/pages/details1/">click here</a>.</p>
</body>
</html>
@elias1435
Copy link
Author

sometime need to exclude certain url. we can do this easily

`<?php
// Define the excluded URLs
$excluded_urls = array(
"/wp-content/uploads/2023/04/link.png",
"/team/memeber-name/"
);

// Get the requested URL
$request_uri = $_SERVER['REQUEST_URI'];

// Check if the requested URL is in the excluded URLs array
if (!in_array($request_uri, $excluded_urls)) {
// Redirect to 'https://www.example.com' for all other URLs
header("Location: https://www.example.com", true, 301);
exit();
}
?>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment