65750

301 redirect in htaccess

Question:

I changed the URL of my articles so I need to be able to redirect them all, but this is how I had it set before in htaccess:

RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ index.php?tag=industry&slug=$1&id=$2

Which would give me something like:

site.com/industry/blah-blah.6842/

Now with my new site, I have the URLs set like this:

site.com/blah-blah/

So how I can do a 301 redirect in htaccess? I can't do all the articles individually because there's tons of them.

I need to be able to redirect this:

^industry/([a-zA-Z0-9-]+).([0-9]+)/$ to this: ^/([a-zA-Z0-9-]+)/$

Thanks in advance.

Answer1:

RewriteRule ^industry/([a-zA-Z0-9-]+).([0-9]+)/$ /$1/ [R=301]

Recommend

  • Serial port - how to perform safe search for my device?
  • Nightmare / Electron : Navigation Error (code - 118)
  • Zend\\ServiceManager\\ServiceManager::get was unable to fetch or create an instance for getAlbum
  • CUBA : entity inheritance
  • How to remove special characters in file names?
  • PHP Explode from first number (integer)
  • Parsing tokens with PLY
  • .htaccess mod rewriterule and ampersands
  • Zend Framework 2 - Building a simple form with Validators
  • Help with mod_rewrite
  • htaccess settings for angularJS pushstate
  • Removing the .php file extension from the URL Request
  • Mod rewrite redirection to another domain if file not exist
  • Using an enum contained in a Cloud Endpoint model on a Android client
  • Many to Many in Linq using Dapper
  • Regex for URL rewrite with optional query string parameters
  • Python pandas melting data to multiple columns and coulmn names in another column
  • Android device acting as an accessory
  • Regex to match a string not followed by anything
  • Apache RewriteRule redirection with url encoded
  • htaccess add www if not subdomain, if subdomain remove www
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • ilmerge with a PFX file
  • Email format validation in mvc3 view
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Spring Data JPA custom method causing PropertyReferenceException
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Excel - Autoshape get it's name from cell (value)
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • How to make Safari send if-modified-since header?
  • Adding custom controls to a full screen movie
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory
  • Conditional In-Line CSS for IE and Others?