301 redirect from dynamic URL in subfolder to a new static URL?

Please try to fill a rewritemap file (see here ) to make a correspondance with the URL destination.

Please try to fill a rewritemap file (see here) to make a correspondance with the URL destination. Create a mapfile where you put all the categories you need: RewriteMap mapoldtonew \ dbm:/web/htdocs/yoursite/rewriterules/mapoldtonew. Map Regarding your sample, your map file may be filled with things like: art_id=61 articles/2/tipos-de-sociedades ... Then here you go for the hard part: RewriteCond %{REQUEST_URI} desarrollo/(.*) RewriteCond %{QUERY_STRING} ((^=+)=(0-9+)) # The following rule doesn't touch the URL, but # will try to search into the map file and # create an OLDTONEW environment variable with the string found # and if not found, assign OLDTONEW to "notfound" RewriteRule .

- QSA,E=OLDTONEW:${mapoldtonew:%1|notfound} # if the OLDTONEW is not empty and is not found: RewriteCond %{ENV:OLDTONEW} notfound # this should never happen => 404: RewriteRule . - R=404,L # Reach here means : # - OLDTONEW is empty # - OLDTONEW is was found # => if OLDTONEW is not empty: RewriteCond %{ENV:OLDTONEW}! ^$ # make the redirection to the corresponding found: RewriteRule .

/%{ENV:CATEGORYREVERSE} QSA,L This should work. If it doesn't try to change %1 to %2 in the first RewriteRule directive. If it still doesn't you may have enough clues to finish the job.

If you don't have enough clues... Two hints: Please try to use the RewriteLog directive: it helps you to track down such problems: # Trace: # (!) file gets big quickly, remove in prod environments: RewriteLog "/web/logs/mywebsite.rewrite. Log" RewriteLogLevel 9 RewriteEngine On My favorite tool to check for regexp: http://www.quanetic.com/Regex (don't forget to choose ereg(POSIX) instead of preg(PCRE)! ).

Bad news I got an Internal Server Error I tried both options %1 and %2 The server encountered an internal error or misconfiguration and was unable to complete your request. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. Apache mod_qos/9.69 mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.

2.2635 Server at mysite.com Port 80 – pedrohd Nov 24 at 2:15.

Related Questions