简体   繁体   中英

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.

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

您将必须使用mod_rewrite和.htaccess文件来实现此目的(如果正在运行的是Apache)。

If you are using Apache, you can use mod_rewrite to do this.

A nice article about it: Using htaccess Files for Pretty URLS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM