Reputation: 59
I enabled the.Htaccess Apache feature. For my localhost wamp it works, because ErrorDocument 404 effect,but it seems only RewriteRule doesn't effect,Is there a problem I have written??And how to write the statement that be Annotated?Thanks a lot! These urls are not working:
RewriteRule ^/(.*)$ http://www.163.com/ [L]
1.RewriteRule ^http://localhost/app/track/([0-9]+)$ /index.php?app=$1
2.RewriteRule ^http://localhost/app/track/123$ /index.php?app=123
Upvotes: 0
Views: 110
Reputation: 59
For:
RewriteRule ^localhost/app/track/([0-9]+)$ /index.php?app=$1
RewriteRule ^localhost/app/track/123$ /index.php?app=123
Delete the 'localhost/' and it works well.
I think The regexp Pattern doesn't match because my DocumentRoot with '/'.
/////
To help understand,I wrote the pseudo-code by php,reference,welcome corrections :)
$realPath = str_replace('http://localhost',DocumentRoot,$url);
redirect(test($realPath));
function test($realPath) {
$pass = false;
if(preg_match($argRegExp, str_replace(DocumentRoot, '', $realPath))) {
if(strpos($argRewriteUrl,'?') ===false){
$realPath = $argRewriteUrl.'/'.basename($realPath);
$pass = $realPath;
}else{
getArgs($realPath);//split ?xx=xx&...
}
if($realPath) {
if($r = test($realPath)){
$pass = $r;
}
}
}
if($pass) {
if($r = test($realPath)){
$pass = $r;
}
}
return $pass;
}
Upvotes: 0