htaccess的搜索引擎友好的URL - 重定向页面重定向、友好、页面、搜索引擎

2023-09-02 20:40:24 作者:一心藏一人

我在看的.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/
 
Google搜索引擎中的安全漏洞 通过开放重定向窃取其他站点的权重

我得到一个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

 
精彩推荐
图片推荐