.htaccess 平面链接 url 缩短

发布于 2024-09-19 23:44:57 字数 541 浏览 4 评论 0原文

我有一个域名 owp.me,我想使用 htaccess,以便我可以转换为以下域名。

http://owp.me/id?=0f49http://owp.me/0f49

“id”仅接受 AZ、az、0-9

我将如何设置重写 RewriteRule ?

编辑:

我已经找到了如何做 http://owp.me/hi/0f49

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^hi/([^/]+) /index.php?id=$1 [NC]

但不能'看看如何删除“hi”并使其正常工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丶情人眼里出诗心の 2024-09-26 23:44:57

找到了答案。从 Yourls 获取 .htaccess 文件 (http://code.google.com/p/yourls/< /a>)

<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>

希望这对其他人有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文