Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. The following would go in .htaccess for the root web directory:
  2. Options +FollowSymLinks
  3. RewriteEngine On
  4. RewriteRule ^([0-9A-Za-z]+)$ /test.php?id=$1 [L]
  5.  
  6. This works where test.php is the file you want to get the ID, and ([0-9A-Za-z]+) is a regular expression that matches the IDs you're passing.
  7.  
  8. For example, site.com/42 would be rewritten to site.com/test.php?id=42
  9.  
  10. Using that particular regex is handy because it matches typical shortener IDs (eg, j8E3g), but won't fuck with people trying to get to folders or files in the same directory, because it doesn't match "/" or ".".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement