Mobile app version of vmapp.org
Login or Join
Jessie594

: PHP URL Shortening/Re-Writing I'm looking to shorten some links, by re-directing. I'm wondering what the best way to do this is: I have files at www.mysite.com/qr/quicklinks/User/ but I'm wondering

@Jessie594

Posted in: #Htaccess #Php #Redirects

I'm looking to shorten some links, by re-directing. I'm wondering what the best way to do this is: I have files at mysite.com/qr/quicklinks/User/ but I'm wondering if it's possible to somehow make it so it's just mysite.com/user? This would be brilliant if it can be done and possibly in PHP too? I've tried a few things but nothing seems to be working.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

2 Comments

Sorted by latest first Latest Oldest Best

 

@Angie530

You know you can just use Bit.ly for free and they have an api where your site can generate URLs.

10% popularity Vote Up Vote Down


 

@Ravi8258870

Use a .htaccess file and mod_rewrite:

RewriteEngine on
RewriteBase /
RewriteRule ^qr/quicklinks/(.*)$ www.example.com/ [R=301,L]


Depending on the server, that's case-sensitive. Adjust the URL if necessary.

If that fails, try this PHP code:

<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: www.site.com/Users/ );
?>


It won't support wildcard files though.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme