Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directing non extension files to .php

I have a file with .php extention www.example.com/thefile.php?name=123 that I want to direct the user to if the user visits any of the following aliases:

www.example.com/alias?name=123
www.example.com/unreal?name=123
www.example.com/fake?name=123

Is there a way I can get this done without using a framework that already uses this structure? I'm using pure php.

like image 895
Chris Avatar asked Nov 17 '25 19:11

Chris


1 Answers

Yes you can, if you have mod_rewrite activated on your Apache Server, you can add a .htaccess file at the root of your website and have something like this into it (not 100% sure since I don't have Apache here at home) :

RewriteRule ^(alias|unreal|fake)$ thefile.php [QSA]

You can consult Apache mod_rewrite doc here

like image 153
MaxiWheat Avatar answered Nov 20 '25 08:11

MaxiWheat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!