0

I want to remove .php from the link in form's action attribute.

the link is:

localhost/shopproject/MassUpload/create_excel.php/createExcel.

I've tried using .htaccess from other questions, but I find only the way to remove .php at the very end of the link e.g

localhost/shopproject/MassUpload/create_excel.php/createExcel.php

to

localhost/shopproject/MassUpload/create_excel.php/createExcel.

I wonder how can I make the link to:

localhost/shopproject/MassUpload/create_excel/createExcel

If it isn't possible is there a better way so that I can hide the usage of create_excel.php from a user?

Thank you for the help

Gufran Hasan
  • 6,461
  • 7
  • 26
  • 41
rhog23
  • 191
  • 12
  • 2
    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) –  Apr 03 '18 at 03:31
  • Not sure but try `RewriteRule ^shopproject/MassUpload/create_excel/createExcel$ shopproject/MassUpload/create_excel.php/createExcel [NC,L] ` – Viney Apr 03 '18 at 03:35

1 Answers1

3

if you ONLY need it for this specific form...

RewriteEngine ON
RewriteRule ^create_excel/createExcel$ create_excel.php/createExcel.php

or if you have a lot of different forms using something like this...

RewriteEngine ON
RewriteRule ^(.*)/(.*)$ $1.php/$2.php

Please note, you probably need to add the correct path that your live website uses.

I think something like this (if you added in proper paths) may be able to help you. I haven't done rewrites in a while, but this would say /anything/whatever is the same as /anything.php/whatever.php

so this would be like saying that /create_excel.php/createExcel.php can be accessed through create_excel/createExcel

If this doesn't work, or you can't create something similar in .htaccess, please try the following I suppose...

create_excel/createExcel/index.php This would allow you to use site.com/create_excel/createExcel/ as a link, because index.php is automatically used (and not displayed in URL bar) when you set up a folder for this.

If you are using some sort of third party library or system, I highly recommend not creating a custom folder like this.

Nerdi.org
  • 633
  • 4
  • 12