0

I'm doing a site in core php. There is a page to verify certificates when students enter their certification id. This is the link to which its redirected when students enter their certification id and click verify.

http://domainname.com/certificate/?id=6785

I need the link to be http://domainname.com/certificate/6785

I've tried adding this code to .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^/certificate/([0-9]+) /certificate/?id=$1
</IfModule>

But it doesn't work.

Can someone please help me?

Moneer Kamal
  • 1,837
  • 16
  • 25
  • 1
    Possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – Masivuye Cokile Oct 18 '19 at 10:47
  • 1
    Try removing the leading `/` in the pattern, i.e.: `RewriteRule ^certificate/([0-9]+) /certificate/?id=$1` – CD001 Oct 18 '19 at 10:48
  • What does "it doesn't work" actually mean? Do you get an error? Which? Do you get redirected or rewritten to something unexpected? Does nothing happen at all? Does the universe implode? You need to make sure that the rewriting module is actually loaded into the http server and that the interpretation of dynamic configuration files is actually enabled for that host and location. And you need to start monitoring your http server's error log file... – arkascha Oct 18 '19 at 11:01
  • 1
    Actually `RewriteRule ^/?certificate/(\d+)$ /certificate/?id=$1 [END]` would be a better solution... – arkascha Oct 18 '19 at 11:01
  • @arkascha - technically yup... since the leading `/` is required when used in something like httpd-vhosts.conf but not in .htaccess, putting it in as an optional match makes sense. – CD001 Oct 18 '19 at 11:45
  • @arkascha what's the relevance of "Does the universe implode?" to his question? – rai Oct 18 '19 at 11:51
  • @rai Well, since the OP does not name what actually happens we do not know. So we start guessing. And in my eyes it would be an important thing to find out if a request to that setup makes the universe implode. Which is why I asked it. – arkascha Oct 18 '19 at 11:53

0 Answers0