【问题标题】:Apache Redirect from a folder to a index.php fileApache 从文件夹重定向到 index.php 文件
【发布时间】:2017-06-09 04:04:38
【问题描述】:

我想从http://www.domain.com/customer1 to /app/index.php?c=customer1http://www.domain.com/customer2 to /app/index.php?c=customer2 重定向

我尝试了以下规则但效果不佳...

RewriteRule ^customer1(.*)$ /app/index.php?c=customer1

【问题讨论】:

标签: apache .htaccess rules


【解决方案1】:

我假设你在谈论重写,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)$ /app/index.php?c=$1 [QSA,L]

如果不重写,这将在内部重写您的网址,然后尝试这样,

RewriteEngine on
RerwiteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)$ /app/index.php?c=$1 [R=301,QSA,L]

【讨论】:

  • 这不起作用...我想打开 domain.com/customer1 并且 apache 重定向到:domain.com/app/index.php?c=customer_code
  • 你是否尝试过both规则以及你想要重定向或重写什么?
  • 重写更好,我已经有了以下规则和工人。实际上规则 RewriteRule ^customer1(.*)$ /app/index.php?c=9898373c7484(customer number) 所以重定向应该是从“客户名称”到“客户编号”,没有客户可以看到他的“号码”
猜你喜欢
  • 2018-09-30
  • 1970-01-01
  • 2016-05-08
  • 2012-10-23
  • 1970-01-01
  • 2016-09-27
  • 2016-03-12
  • 2013-08-18
  • 1970-01-01
相关资源
最近更新 更多