dpg76975
2016-08-31 12:25
浏览 56
已采纳

从example.com/script.php?param=value到example.com/value的Nginx重写

I have a PHP script that accepts a single parameter.

My project structure is like the following:

index.php
i.php
terms.php
functions
includes
icons
resources

The script that I want to rewrite its URL is i.php from

example.com/i.php?icon=id

to

example.com/id

While making sure everything else is normally accessible (e.g. example.com/terms.php).

How do I do that?

Edit This might be helpful. Here's my previous .htaccess that I used to use on my apache server:

Options +FollowSymLinks  
RewriteEngine On  

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^(\w+)$ ./i.php?icon=$1

图片转代码服务由CSDN问答提供 功能建议

我有一个接受单个参数的PHP脚本。</ p>

我的项目 结构如下所示:</ p>

  index.php 
i.php 
terms.php 
functions 
includes 
icons 
resources 
 </ code> </ pre> \  n 
 

我要重写其URL的脚本是 i.php </ code>来自</ p>

  example.com/i.php?icon  = ID 
 </代码> </ PRE> 
 
 

到</ p>

 <代码> example.com/id
 </代码> </ PRE> \  n 
 

确保其他所有内容都可以正常访问(例如 example.com/terms.php </ code>)。</ p>

我该怎么做?< / p>

编辑</ strong> 这可能会有所帮助。 这是我之前在我的apache服务器上使用的.htaccess:</ p>

  Options + FollowSymLinks 
RewriteEngine On 
 
RewriteCond%{SCRIPT_FILENAME}!-d 
RewriteCond%{  SCRIPT_FILENAME}!-f 
RewriteRule ^(\ w +)$ ./i.php?icon=$1
</ div>

2条回答 默认 最新

相关推荐 更多相似问题