这个问题已经在这里有一个答案:
- htaccess的PHP重写view.php?visopslag =(ID) 2个答案
我用我的.htaccess文件中添加www.
索引网址,删除.php
和删除?id=
从URL中。
这是原始地址:
www.site.com/article.php?id=12&title=title-text
网址的.htaccess代码
www.site.com/article/12
此代码已删除了&title=title-text
的URL。
如何删除&title=
无title-text
? 像这样:
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