我想为我的博客创建 SEO url 我的博客 url 就像 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 尝试了类似的代码,但它起作用了。
最佳答案
your URL should be
http://localhost/test/1
RewriteRule ^test/([a-zA-Z0-9_-]+)/$ blog.php?blogId=$1 [NC]
关于php - 使用 .htaccess 创建 SEO 网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32499948/