重写转义标签#%23

时间:2015-07-30 03:56:57

标签: apache mod-rewrite redirect url-rewriting

我最近注意到来自URL的传入404错误命中,其主题标签被转义。

更正网址结构: var app = angular.module("app", []); app.factory('mainInfo', function($http) { var getRecordsPromise = $http.get('http://localhost/test.php').then(function(response){ //whatever is returned here will be accessible in the .then that is chained return response.data.records; }); return { getRecords: getRecordsPromise }; }); app.controller('Ctrl', function($scope, mainInfo){ mainInfo.getRecords.then(function (records) { $scope.foo = records; }); }) ; http://example.org/#!/thepage

转义/错误的网址: /index.html#!/thepage

我尝试了以下.htaccess规则但收效甚微:

http://example.org/%23!/thepage

1 个答案:

答案 0 :(得分:0)

感谢这个答案,我指出了正确的方向:https://webmasters.stackexchange.com/a/76059

这是适用于我的规则

RewriteRule ^\x23!/(.*)$ http://www.example.org/index.html#!/$1 [L,R=301,NE]

使用\x时,它会匹配以%

开头的转义字符