0

i'm trying to remove ? from the URL currently url is showing as

http://www.tenantfind.co.uk/blog-detail.php?id=4

and it should open as

http://www.tenantfind.co.uk/blog/new-legal-helpline

i tried the following solution

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(blog-detail)?\?([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog-detail?$1 [L]

but it is redirecting to following link and showing blank page, no data on page

http://www.tenantfind.co.uk/blog-detail
Kashif Latif
  • 657
  • 3
  • 15
  • 29

1 Answers1

1

Try with:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(?:blog-detail)?\?([^&\ ]+)
RewriteRule ^ /blog/%1? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)/?$ /blog-detail?$1 [L]
Croises
  • 18,570
  • 4
  • 30
  • 47
  • URL is exactly the same as I want but it is not displaying any page and showing **Internal Server Error** – Kashif Latif Nov 12 '15 at 13:09
  • Without htaccess, your link `http://www.tenantfind.co.uk/blog-detail?Full-management-services` worked ? – Croises Nov 12 '15 at 13:53
  • While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) out of the code really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – Kyll Nov 12 '15 at 16:32
  • @Croises yup it's working fine without adding this code in .htaccess file... you can check live link – Kashif Latif Nov 12 '15 at 16:45
  • @Croises i just update it and update my question also, you can see now – Kashif Latif Nov 13 '15 at 08:06
  • Yes, but you can not change the subject and hoped that the answers will continue to work. Without me, because what you ask now is not possible only with .htaccess. – Croises Nov 13 '15 at 08:13
  • Read: http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained – Croises Nov 13 '15 at 08:17