0

Please help me with RewriteCond

I have website www.website.com/read.php?slug=my-page-title

I want to have rewrite URL like this www.website.com/my-page-title

This is my .htaccess

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /read\.php\?slug=([^\s&]+) [NC]
RewriteRule ^read\.php$ /%1? [R=301,L]

RewriteRule ^/([^/]+)/?$ /read.php?slug=$1 [NC,L]

It shows me 404 error with the rules above. Kindly assist

mydreamadsl
  • 568
  • 4
  • 16
  • 25

1 Answers1

0

You need to remove the leading slash from your rule as RewriteRule's pattern is relative to the current directory.

RewriteRule ^([^/]+)/?$ /read.php?slug=$1 [L]
Amit Verma
  • 40,709
  • 21
  • 93
  • 115