Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess HTACCES:更改url更友好_.htaccess_Url Rewriting - Fatal编程技术网

.htaccess HTACCES:更改url更友好

.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

我想让我的网站的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} \ /+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="/" />