我想为我的博客创建搜索引擎优化网址,我的博客网址像http://localhost/test/blog.php?blogId=5,我想把它转换成博客标题。
我目前正在.htaccess页面中尝试此功能,但不起作用
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?u=$1
RewriteEngine ON
RewriteRule ^([a-zA-Z0-9_-]+)$ blog.php?blogId=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ blog.php?blogId=$1奇怪的是,我为用户id尝试了一个类似的代码,它起作用了。
发布于 2015-09-10 19:07:02
your URL should be
http://localhost/test/1
RewriteRule ^test/([a-zA-Z0-9_-]+)/$ blog.php?blogId=$1 [NC]发布于 2015-09-10 19:23:21
试着这样写吧。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?u=$1 [NC,L] # for user id's no slash
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^([a-zA-Z0-9_-]+)/$ blog.php?blogId=$1 [NC,L] # for blog with slash指向用户to的链接将类似于/2
指向博客文章的链接将类似于/2/
https://stackoverflow.com/questions/32499948
复制相似问题