Created
May 1, 2020 12:30
-
-
Save tdwesten/162a46d343e3d9418a9835f68d0ef529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class LocalValetDriver extends WordPressValetDriver { | |
/** | |
* Determine if the incoming request is for a static file. | |
* | |
* @param string $sitePath | |
* @param string $siteName | |
* @param string $uri | |
* | |
* @return string|false | |
*/ | |
public function isStaticFile( $sitePath, $siteName, $uri ) { | |
if ( ( stripos( $uri, 'wp-admin' ) !== false || stripos( $uri, 'wp-content' ) !== false || stripos( $uri, 'wp-includes' ) !== false ) ) { | |
$staticFilePath = $sitePath . substr( $uri, stripos( $uri, '/wp-' ) ); | |
} else { | |
$staticFilePath = $sitePath . $uri; | |
} | |
if ( $this->isActualFile( $staticFilePath ) ) { | |
return $staticFilePath; | |
} else if ( preg_match( "/\.(js|css|png|jpe?g|gif|ico|svg)$/", $uri ) ) { | |
header( "Location: https://www.production-server.nl{$uri}", false, 301 ); | |
exit; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment