【问题标题】:Using .htaccess redirect php url to another使用 .htaccess 将 php url 重定向到另一个
【发布时间】:2014-07-25 11:47:54
【问题描述】:

我最近为我的 VPS 创建了子域,我想在 URL 中重定向 .php

http://bn.domain.com/forum/register.php

我希望它们被重定向到适当的 URL:

http://bn.domain.com/anonpanel/

我该怎么做?

[2014 年 6 月 4 日星期三 20:10:57] [警报] [客户端 202.62.25.9] /var/www/forum/.htaccess:无效的命令“RewriteEngine”,也许 由未包含在服务器中的模块拼写错误或定义 配置 [2014 年 6 月 4 日星期三 20:11:01] [警报] [客户端 202.62.25.9] /var/www/forum/.htaccess:无效的命令“RewriteEngine”,也许 由未包含在服务器中的模块拼写错误或定义 配置 [2014 年 6 月 4 日星期三 20:13:01] [警报] [客户端 114.79.13.26] /var/www/forum/.htaccess:无效的命令“RewriteEngine”,也许 由未包含在服务器中的模块拼写错误或定义 配置 [2014 年 6 月 4 日星期三 20:13:03] [警报] [客户端 114.79.13.26] /var/www/forum/.htaccess:无效的命令“RewriteEngine”,也许 由未包含在服务器中的模块拼写错误或定义 配置

【问题讨论】:

  • 不清楚,能否再澄清一下您的要求。
  • 只需将 domain.com/forum/register.php 重定向到 domain.com/anonpanel

标签: regex apache .htaccess mod-rewrite


【解决方案1】:

您可以在/forum/.htaccess 文件中使用此规则:

RewriteEngine On
RewriteBase /forum/

RewriteCond %{HTTP_HOST} ^bn\.domain\.com$ [NC]
RewriteCond %{THE_REQUEST} /register\.php[?/\s] [NC]
RewriteRule ^ /anonpanel [L,NC,R]

【讨论】:

  • 我在使用 htaccess 时遇到内部服务器错误,顺便说一句,不是 domain.com 而是 bn.domain.com
  • 您确定mod_rewrite 已打开吗?检查您的 Apache error.log 以了解 500 错误的原因。
  • 该日志表示mod_rewrite 未启用。您需要在 Apache 服务器中启用它。
  • 我已经更新了 /etc/apache2/sites-available/default 中的 AllowOverride All,然后重启 apache2 服务
猜你喜欢
  • 2013-08-04
  • 2022-01-13
  • 2015-10-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多