Skip to content

Instantly share code, notes, and snippets.

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 tdwesten/162a46d343e3d9418a9835f68d0ef529 to your computer and use it in GitHub Desktop.
Save tdwesten/162a46d343e3d9418a9835f68d0ef529 to your computer and use it in GitHub Desktop.
<?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