-1

i want to rewrite url from page.php?id=something-new-url-5dd669f4882a6 to domain.com/something-new-url-5dd669f4882a6 i have done some htaccess practices but it is not working. here are my codes.

Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/page\.php\?id=(.*)\s [NC]
RewriteRule ^ /%1? [R=301,L]

my project is in directory like ,

www.example.com/demo/page.php?id=something-new-url-5dd669f4882a6 

and i want to make it seo friendly

domain.com/demo/something-new-url-5dd669f4882a6
Ayaan
  • 9
  • 2
  • 1
    You did not consider the `demo` folder in the pattern inside your rewriting condition. – arkascha Nov 21 '19 at 11:30
  • i have changed folder, still its saying 404 not found. Options -MultiViews RewriteEngine On # redirect "/section.php?id=xxx" to "/section/xxx" RewriteCond %{THE_REQUEST} \s/page\.php\?id=(.*)\s [NC] RewriteRule ^ /demo/%1? [R=301,L] – Ayaan Nov 21 '19 at 11:34
  • 1
    I wrote in the pattern of the condition, not in the rule's target. – arkascha Nov 21 '19 at 12:06

1 Answers1

1

Look this: redirect in php

Page.php:

<php>

    $tb=explode('=', $_GET);
    if (isset($tb[1]) && $tb[0]=='id') header('Location: domain.com/demo/' . $tb[1]);
    exit();

</php>