Skip to content
This repository has been archived by the owner on Feb 22, 2025. It is now read-only.

A function/class for use in shortening URL links.

Notifications You must be signed in to change notification settings

stevenvachon/absolute-to-relative-urls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

absolute-to-relative-urls

The title says it all. So, if you were to use this library on a website like http://example.com/test/testing/, you would get results like these:

    • Before: http://example.com/test/another-test/#anchor
    • After: ../another-test/#anchor
    • Before: http://example.com/wp-content/themes/twentyten/style.css
    • After: /wp-content/themes/twentyten/style.css
    • Before: https://example.com/wp-content/themes/twentyten/style.css
    • After: https://example.com/wp-content/themes/twentyten/style.css
    • Before: http://google.com/test/
    • After: //google.com/test/
    • Before: ../../../../../../../../#anchor
    • After: /#anchor
    • After ($output_type=1): ../../#anchor

All string parsing. No directory browsing.

Usage

<?php
echo absolute_to_relative_url('http://your-domain.com/dir/');
?>

or

<?php
$instance = new Absolute_to_Relative_URLs('http://remote-site.com/');
 
echo $instance->relate_url('http://remote-site.com/dir/', false, 0);
?>

About

A function/class for use in shortening URL links.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages