Redirect 301 / Rewrite Puzzle

On my site, users can add various URLs that need to be redirected.

For instance; from this: domain.com/oldpage/36/

To this: domain.com/newpage/47/

They are added to .htaccess as follows:

Redirect 301 /oldpage/36/ /new-page/47/

But when accessing the old page, they get the following:

domain.com/newpage/47/?pid=36&pagename=oldpage

I am sure that these rewrite rules cause this predicament:

RewriteRule ([^.]+)/([0-9]+)/$ index.php?pid=$2&pagename=$1
RewriteRule ([^.]+)/([0-9]+)/([^.]+) index.php?pid=$2&pagename=$1&vars=$3

However, mod_rewrite stuff is not my strong point, so I have no idea how to fix it.

Any ideas?

+3
source share
2 answers

Adding ?does Rewritenot add the query string to the url.

so this should work:

Redirect 301 /oldpage/36/ /new-page/47/?

:

RewriteRule ([^.]+)/([0-9]+)/$ index.php?pid=$2&pagename=$1?
RewriteRule ([^.]+)/([0-9]+)/([^.]+) index.php?pid=$2&pagename=$1&vars=$3?

+2

mod_rewrite , , ,

RewriteRule /oldpage/36/ /new-page/47/ [R=301]

"" URL- URL- 301. [R] , , , URL-.

+2

All Articles