I'm trying to write a 301 in our .htaccess file but can't get it working. We have url's like the following…
http://www.example.com/?cat=tree-category
http://www.example.com/?cat=food-category
We would like to change these to
http://www.example.com/directory/listings/tree-category
http://www.example.com/directory/listings/food-category
Could anyone help please, it would be very appreciated!
James
This should do it:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{QUERY_STRING} ^cat=([a-zA-Z0-9\-]*)$
RewriteRule ^(.*)$ http://www.example.com/directory/listings/%1 [R=301,L]
Check out: http://www.simonecarletti.com/blog/2009/01/apache-query-string-redirects/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.