从URL地址栏中删除子目录和ID

时间:2017-07-27 05:27:50

标签: php .htaccess

目前我的网址是:

http://welcome.something.com/task/demo-log.php?id=worklog

http://welcome.something.com/task/demo-team.php?id=team

我有类似的多个网址。

直到 http://welcome.something.com/task/demo-外翻是一样的。我创建了htaccess

RewriteEngine on
RewriteCond %{THE_REQUEST} \ /(.*/|)(?:demo-log\.php)?\?id=([^\s&]+) [NC]
RewriteRule ^ /%1%2? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*/|)([^/]*)$ $1demo-log.php?id=$2 [L]

在当前的htacess代码的帮助下,我能够得到这个

http://welcome.something.com/task/worklog

现在我要删除任务子目录(例如此http://welcome.something.com/worklog)并将此网址规则应用于我的所有文件,例如

http://welcome.something.com/task/demo-team.php?id=team要更改为

http://welcome.something.com/team

0 个答案:

没有答案