Forum Moderators: phranque
Where does this come into play:
"GET /somepath/somefile?someextension HTTP/1.1"
# Externally redirect direct client requests for old/unfriendly/query-stringed URLs to new friendly URLs
#
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /view\.php\?id=1\ HTTP/
RewriteRule ^view\.php$ http://www.example.com/industrial-products/? [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /view\.php\?id=2\ HTTP/
RewriteRule ^view\.php$ http://www.example.com/domestic-products/? [R=301,L]
#
#
# Internally rewrite friendly URL requests to internal script filepath plus query
#
RewriteRule ^industrial-products$ /view.php?id=1 [L]
#
RewriteRule ^domestic-products$ /view.php?id=2 [L]
# Externally redirect direct client requests for old/unfriendly/query-stringed URLs to new friendly URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /view\.php\?id=([0-9]+)\ HTTP/
RewriteCond %1>industrial ^1>(.+)$ [OR]
RewriteCond %1>domestic ^2>(.+)$ [OR]
RewriteCond %1>discontinued ^3>(.+)$ [OR]
RewriteCond %1>custom ^4>(.+)$
RewriteRule ^view\.php$ http://www.example.com/%1-products/? [R=301,L]
#
# Internally rewrite friendly URL requests to internal script filepaths
RewriteCond $1>1 ^industrial>(.+)$ [OR]
RewriteCond $1>2 ^domestic>(.+)$ [OR]
RewriteCond $1>3 ^discontinued>(.+)$ [OR]
RewriteCond $1>4 ^custom>(.+)$
RewriteRule ^([^/\-]+)-products$ view.php?id=1 [L]
http://www.example.com/view.php?id=anynumber -> http://www.example.com/anytext/
http://www.example.com/42211/ /*equivalente to http://www.example.com/view.php?discussion=42211*/
/*but we want to show this: */
http://www.example.com/you-can-buy-the-new/
www.example.com/42211-you-can-buy-the-new then there is a solution for the internal rewrite: RewriteRule ^([0-9]+)-(.*) /view.php?id=$1&name=$2 [L]