Home>

The "html file" in the hoge directory is

RewriteRule (. *). html AAA.php? bbb = $1.html [R = 301, L]

Instead of simply displaying "hoge/xxx.html",
"Hoge/AAA.php? Bbb = xxx.html" is displayed with php in between.
It is assumed that this structure cannot be changed.

Error message

When xxx.html is accessed because xxx.html is no longer needed
I want to redirect to yyy.html, but I don't know how to write.

Redirect could not be performed with the following description.

RewriteEngine on
RewriteBase/hoge /
RewriteCond% {REQUEST_URI}! (/ Xxx.html $) ← If i delete this, you will not be redirected
RewriteRule (. *). Html AAA.php? Bbb = $1.html [R = 301, L]
RewriteEngine on
RewriteBase /
RewriteRule AAA.php? Bbb = xxx.html http: //hoge/yyy.html [R = 301, L]
RewriteRule xxx.html http: //hoge/yyy.html [R = 301, L]

I would be grateful if you could help me. .

  • Answer # 1

    Simply ...

    RewriteRule ^ (. *) xxx \ .html $AAA.php? bbb = yyy.html [R = 301, L]
    RewriteCond% {QUERY_STRING} bbb = xxx.html
    RewriteRule ^ AAA.php AAA.php? Bbb = yyy.html [L, R = 301]

    "hoge/xxx.html" becomes "hoge/AAA.php? bbb = yyy.html".
    "Hoge/AAA.php? Bbb = xxx.html" and "hoge/AAA.php? Bbb = yyy.html"
    Rewriting to.

    There may be a better way to write it ...

  • Answer # 2

    I've checked it out ...

    RewriteRule ^ (. *) xxx \ .html $http: // hoge/zzz/[R = 301, L]
    RewriteCond% {QUERY_STRING} bbb = xxx.html
    RewriteRule ^ AAA.php http: // hoge/zzz/[L, R = 301]

    ↓↓↓↓↓

    RewriteRule ^ (. *) xxx \ .html $http: // hoge/zzz/[R = 301, L]
    RewriteCond% {QUERY_STRING} ^ bbb = xxx.html $
    RewriteRule ^ AAA.php $http: // hoge/zzz /? [L, R = 301]
    By doing

    , I was able to erase the query (parameter?)! !
    This time, thank you very much! ! I am very grateful to you.