【问题标题】:page redirect with .htaccess [custom URLs]使用 .htaccess [自定义 URL] 重定向页面
【发布时间】:2015-05-15 18:54:55
【问题描述】:

我想做一个推荐系统,但它是基于一个推荐系统来查找它在数据库中的值,我想用这个代码重定向用户的页面。我试图解释链接的结构应该在底部。我们如何做到这一点?

数据库 --> USERCODE(A6465S) --> example.com/A6465S(USERCODE) --> USER PAGE(REDIRECT) --> site.com/users.php?id=10 --> 完成

【问题讨论】:

  • 你的意思是example.com/123重定向 example.com/user.php?id=123
  • 对于我使用 AltoRouter 的东西 - 你可以很容易地找到它。
  • 如何从A6465S10
  • @Starkeen 我想照你说的做 :) 请帮帮我 :(

标签: php mysql .htaccess redirect


【解决方案1】:

在你的 root/htaccess 文件中试试这个:

#turn on the engine for rewriting
RewriteEngine On

#if the request  is for a existing file or directory, then skip the rewrite rule
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

#Rewrite the short url
RewriteRule ^([a-zA-Z0-9]+)/?$ /users.php?id=$1 [QSA,L]

【讨论】:

  • 你是完美的。非常感谢你,你是最好的。你是一个数字。 [对不起,我正在使用谷歌翻译。]
猜你喜欢
  • 2018-04-18
  • 2016-11-21
  • 1970-01-01
  • 2018-02-04
  • 2017-11-03
  • 2014-12-23
  • 2022-01-19
  • 1970-01-01
  • 2013-12-28
相关资源
最近更新 更多