【发布时间】:2015-06-30 23:24:44
【问题描述】:
我已使用我的 .htaccess 文件将 www. 添加到索引 url,删除 .php 并从 URL 中删除 ?id=。
这是原网址:
www.site.com/article.php?id=12&title=title-text
带有 .htaccess 代码的网址
www.site.com/article/12
此代码已从 url 中删除 &title=title-text。
如何在没有title-text 的情况下删除&title=?像这样:
www.site.com/article/12/title-text
.htaccess 文件
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^ifeelvideos.com [NC]
RewriteRule ^(.*)$ http://www.ifeelvideos.com/$1 [L,R=301]
# To externally redirect /dir/foo.php?id=123 to /dir/foo
RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\?id=([^&\s]+) [NC]
RewriteRule ^ %1/%2? [R,L]
# To internally forward /dir/foo/12 to /dir/foo.php?id=12
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/([^/]+)/?$ $1.php?id=$2 [L,QSA]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\s [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*?)/?$ $1.php [L]
#Alternate default index pages
DirectoryIndex first.html index.htm index.html index.php
【问题讨论】:
标签: php database apache .htaccess url