.htaccess HTACCES:更改url更友好
我想让我的网站的url更友好,更容易被谷歌找到 这是我的网站的url: www.myweb.com/news.php?id=12&title=我的新闻标题 我想变成: www.myweb.com/news/12/title-of-my-news.htaccess HTACCES:更改url更友好,.htaccess,url-rewriting,.htaccess,Url Rewriting,我想让我的网站的url更友好,更容易被谷歌找到 这是我的网站的url: www.myweb.com/news.php?id=12&title=我的新闻标题 我想变成: www.myweb.com/news/12/title-of-my-news 任何人都可以帮助我,htacces上的sysntax?将这些规则添加到文档根目录中的htaccess文件中: Options -Multiviews RewriteEngine On RewriteCond %{THE_REQUEST} \ /+new
任何人都可以帮助我,htacces上的sysntax?将这些规则添加到文档根目录中的htaccess文件中:
Options -Multiviews
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+news\.php\?id=([0-9]+)&title=([^&]+)
RewriteRule ^ /news/%1/%2? [L,R]
RewriteCond %{REQUEST_FILENAME) !-f
RewriteCond %{REQUEST_FILENAME) !-d
RewriteRule ^news/([^/]+)/([^/]+)$ /news.php?id=$1&title=$2 [L]
您还需要确保页面上的所有链接都是绝对URL,或者将其添加到页面标题:
<base href="/" />