我想使用htaccess:
重定向javascript文件的url自:
http://www.domain.co.uk/tracking/tracking.js
要:
http://www/domain.co.uk/Templates/domain.co.uk/tracking/tracking.js
在尝试了很多东西之后,现在我就是这个:
RewriteEngine on
RewriteRule tracking/tracking.js? http://www.domain.co.uk/Templates/domain.co.uk/js/tracking.js [L]
问题是,通过这种配置,我只能访问javascript代码(文件)写入........ / tracking / tracking.js /(最后用斜线,但我不想要它)
答案 0 :(得分:1)
通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在.htaccess
目录下的DOCUMENT_ROOT
中:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.domain\.co\.uk)$ [NC]
RewriteRule ^(tracking/tracking\.js)$ http://%1/Templates/domain.co.uk/$1 [L,R=301,NC]