Apache从文件夹重定向到index.php文件

时间:2017-01-24 11:14:12

标签: apache .htaccess rules

我想从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

1 个答案:

答案 0 :(得分:0)

我假设你在谈论重写,

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]