why does the regex in my rewrite condition seem to not catch?


I have URLs like the following:


and I want to rewrite them as


so I want to replace ?sentence= with a "/"

I have tried all of the following:

RewriteCond %{THE_REQUEST} ^GET\ sentence= [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\ \?sentence= [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\ \?sentence=([^/?&\s]+) [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\s/+\?sentence=([^/?&\s]+) [NC] RewriteRule ^ /%1 [NC,L,NE]

then I tried accessing the URL:


but it stays as it is. I assume my regex logic is not correct and the rewrite cond is never satisfied. I always have trouble with regex.


You can use this rule:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(eng)\?sentence=([^\s&]+) [NC] RewriteRule ^ /%1/%2/? [L,R]

This will redirect http://mysite.com/eng?sentence=dog into http://mysite.com/eng/dog/


  • Redirect all to base domain
  • .htaccess includes old part of url
  • htaccess php_value auto_prepend_file gives me internal 500 error
  • dyanmic url not rewriting ht access
  • Strip down any parameter from URL which is not whitelisted
  • Use htaccess to mask domain and folder name
  • how can i match two strings even if they are 1 character different?
  • Choices defined for model fields not being enforced?
  • “Internal Server Error” with Hello World Python App
  • Too many Redirects after switching WordPress to https
  • Filling web form via PowerShell does not recognize the values entered
  • Morphological Reconstruction in OpenCV
  • Can't access my folder because of WordPress [closed]
  • How to insert data into a Microsoft Access Database?
  • htaccess will not rewrite subdomains
  • Change URL in browser without redirection with htaccess
  • Django how to modify database records by template
  • How do I use cURL & PHP to spoof the referrer?
  • Filter Array Content to a Query containing $concatArrays
  • Can I put a + sign in a folder with IIS?
  • node-postgres UTF password bug
  • Check all commands exit code within a bash script
  • htaccess settings for angularJS pushstate
  • joomla! 1.5.26 and “You are currently logged in to the private area of this site”
  • Mod rewrite redirection to another domain if file not exist
  • Open hyperlink on click on an ggplot/plotly chart
  • Nginx rewrite equivalent to Apache RewriteRule that converts URL params into QueryString key/value p
  • Redirect to trailng slash (htaccess)
  • Symfony2 redirect to https route fails (uses wrong port)
  • SSL client cert authentication for only some URLs?
  • SAXReader not re-ecape characters
  • Apache RewriteRule redirection with url encoded
  • htaccess add www if not subdomain, if subdomain remove www
  • Checking free space on FTP server
  • Rearranging Cells in UITableView Bug & Saving Changes
  • R: gsub and capture
  • AT Commands to Send SMS not working in Windows 8.1
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET