由网友(一心藏一人)分享简介:我在看的.htaccess文件,现在我的网站重定向所有链接到搜索引擎友好的链接例如http://example.com/index.php?page=1到http://example.com/home/1/通过以下code 重写规则^家居/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]但是当...
我在看的.htaccess文件,现在我的网站重定向所有链接到搜索引擎友好的链接
例如
http://example.com/index.php?page=1到
http://example.com/home/1/
通过以下code
重写规则^家居/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]
但是当我到了页
http://www.example.com/home/
我得到一个404错误....
我怎样才能得到它,这样,当/家庭/访问它会自动重定向到/ home / 1 /
解决方案尝试使用:
重写规则^家/?$ http://www.yourdomain.com/home/1 [R = 301,L]
重写规则^家居/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]
R = 301意味着重定向根据 HTTP状态code
i am looking at .htaccess files and have my site now redirect all links to SEO friendly links
e.g
http://example.com/index.php?page=1 to
http://example.com/home/1/
by using the following code
RewriteRule ^home/([0-9]+)/?$ index.php?page=$1 [NC,L]
but when i got to the page
http://www.example.com/home/
i get a 404 error....
How can i get it so that when /home/ is accessed it automatically redirects to /home/1/
解决方案Try with:
RewriteRule ^home/?$ http://www.yourdomain.com/home/1 [R=301,L]
RewriteRule ^home/([0-9]+)/?$ index.php?page=$1 [NC,L]
R=301 means that redirect is permanent according to HTTP status code
相关推荐
最新文章