I'm trying to create a URL shortener service. Most URL shortener services have use a code following the domain. For example, http://bit.ly/duSk8wK, duSk8wK would be the code.
What code is needed in .htaccess file to make the server read the path part 'duSk8wK' and query in database, instead of going to the folder name /duSk8wK?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In your Htaccess, you could make a rewriterule like this:
RewriteRule ^([^/.]*)$ redirect.php/?code=$1 [L]
Then in your redirect.php
, you could simply get the code by using $_GET["code"]
.