无法使用htaccess重定向所有请求

时间:2013-09-17 01:07:40

标签: .htaccess redirect

我试图在我的网站上隐藏真实的网址,所以我拥有的是:

mydomain.com/customers/[customer_name]

重定向到

mydomain.com/scripts/get_customer_page.php?customer=[customer_name]

重定向正常,但get_customer_page.php所需的所有文件CSS / JS文件都无效。

浏览器查看:

mydomain.com/customers/[customer_name]/css

这是我的.htaccess文件的样子:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^customers/(.*)/?$ scripts/get_customer_page.php?customer=$1 [QSA,L]

我该如何解决?

2 个答案:

答案 0 :(得分:0)

将您的链接更改为绝对网址,或将相对URI基础添加到网页标题中:

<base href="/customers/" />

答案 1 :(得分:0)

我最终通过编辑.htaccess文件解决了这个问题:

Options +FollowSymLinks
RewriteEngine On
# When there is not only one "/" i.e. mydomain.com/customers/path_to_some_file
RewriteRule ^customers/(.*/.*)/?$ http://www.mydomain.com/$1 [QSA,L]
RewriteRule ^customers/(.*)/?$ scripts/get_customer_page.php?customer=$1 [QSA]
相关问题