【问题标题】:using .htaccess with paths in php [closed]在php中使用带有路径的.htaccess [关闭]
【发布时间】:2012-12-30 07:42:31
【问题描述】:

我正在编写一个脚本,我想制作如下链接:

www.mysite.com/sites/info/siteid 
www.mysite.com/sites/edit/siteid
www.mysite.com/sites/delete/siteid

我知道我应该使用 RewriteRule。这是我的 .htaccess

RewriteEngine On
RewriteRule ^/?([a-z]+)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^sites/(.*)$ sites.php?info=$1 [L] 

所以,在 php 中,我想获取 /info 或 /edit 或 /delete,如 $_GET['info']; 等等。 另外,我想以同样的方式获得siteid

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    / 处拆分参数应该可以工作

    RewriteRule ^/sites/(.*)/(.*)$ sites.php?info=$1&siteid=$2 [L]
    

    【讨论】:

      猜你喜欢
      • 2011-08-31
      • 2020-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多