Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter MichaelApproved

    (@michaelapproved)

    As a quick fix, I can filter the URL and remove the query, trailing slash, making it all lowercase and tweak it any other way I need.

    Would you be able to include a filter for the URL in the WordPress init function?

    public function init() {
    	$url = $_SERVER['REQUEST_URI'];
    
    //////
    ////// This is a new filter that I'm proposing
    //////
    	$url = apply_filters( 'redirection_url', $url );
    
    	// Make sure we don't try and redirect something essential
    	if ( !$this->protected_url( $url ) && $this->matched === false ) {
    		do_action( 'redirection_first', $url, $this );
    
    		$redirects = Red_Item::get_for_url( $url, 'wp' );
    
    		foreach ( (array)$redirects AS $item ) {
    			if ( $item->matches( $url ) ) {
    				$this->matched = $item;
    				break;
    			}
    		}
    
    		do_action( 'redirection_last', $url, $this );
    	}
    }
    Thread Starter MichaelApproved

    (@michaelapproved)

    To be clear, I’d filter $url to remove the query values, so I’d never have to worry about that breaking my redirects and leave out regex. This saves the effort of creating a UI.

    I could also set the url to be all lowercase, so it’s case insensitive.

    Filtering the $url would be really powerful for customizations.

    Thread Starter MichaelApproved

    (@michaelapproved)

    I created a pull request on the github repo with this change https://github.com/johngodley/redirection/pull/56

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Making it easy to redirect without regex’ is closed to new replies.