.htaccess flat links url shorten
I have a domain开发者_运维技巧 owp.me and I want to use htaccess so that I can convert to following.
http://owp.me/id?=0f49 to http://owp.me/0f49
The "id" will only accept A-Z, a-z, 0-9
How would I set up the rewrite the RewriteRule?
Edit:
I have found how to do http://owp.me/hi/0f49
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^hi/([^/]+) /index.php?id=$1 [NC]
but can't see how to remove the "hi" and make it work properly.
Found the answer. Grabbed the .htaccess file from Yourls (http://code.google.com/p/yourls/)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z]+)/?$ /index.php?id=$1 [L]
</IfModule>
Hope this helps someone else.
精彩评论