重定向原始网址重写网址(htaccess)

时间:2012-06-02 01:23:44

标签: .htaccess mod-rewrite

如何重定向原始网址以重写网址

原始: 域/的index.php?P = 50 重写: 域/后/ 50 /

我试着在这里解释得更好

iF

请求:domain / index.php?p = 50

重定向到:domain / post / 50 /

改写为:domain / index.php?p = 50

谢谢

1 个答案:

答案 0 :(得分:0)

使用此代码:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^post/([0-9]+)$ index.php?p=$1 [L]

你必须以另一种方式思考:

  • 用户将使用domain / post / 50
  • 我会将此网址重写为domain / index.php?p = 50
相关问题