0
votes

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:

  1. RewriteCond %{HTTP_HOST} !^www.163.com [NC]
  2. 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=123enter image description here enter image description here

1
What url is not working? and please post your code in texts.Amit Verma
@starkeen I tried these without a valid one. Why?unscientific! RewriteCond %{HTTP_HOST} !^www.163.com [NC] RewriteRule ^/(.*)$ 163.com [L] <br/> RewriteRule ^localhost/app/track/([0-9]+)$ /index.php?app=$1 RewriteRule ^localhost/app/track/123$ /index.php?app=123shequeen Qin

1 Answers

0
votes

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;
}