的.htaccess平链接url可缩短链接、htaccess、url

2023-09-02 20:35:02 作者:眼里有你

我有一个域owp.me,我想用htaccess的,这样我可以转换成以下。

I have a domain owp.me and I want to use htaccess so that I can convert to following.

http://owp.me/id?=0f49 到的 http://owp.me/0f49

标识将只接受A-Z,A-Z,0-9

The "id" will only accept A-Z, a-z, 0-9

我将如何建立重写重写规则?

How would I set up the rewrite the RewriteRule?

编辑:

我发现怎么办 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.

推荐答案

找到了答案。一把抓起YOURLS .htaccess文件(HTTP://$c$c.google.com/p/yourls/)

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.