Table of Contents
回复讨论(解决方案)

seo : 301重定向

Jun 23, 2016 pm 01:52 PM
301 seo Redirect

比如一个网页 存在两个网址 (例如  www.x.com/you_10_1   和    www.x.com/you_10)都指向它。

现在需要将 www.x.com/you_10_1 使用301重定向到 www.x.com/you_10,请问怎么实现。


回复讨论(解决方案)

都没人吗????求各路大神指教呀

谁来解答一下呀

你是要用PHP来实现还是web服务器来实现?

你的 web 服务器是什么呢?

难不成让人家对所有的服务器写一份教程给你?

不好意思。忘记说了 是 php    服务器是 apache 的

if($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']=='www.x.com/you_10_1'){	header("HTTP/1.1 301 Moved Permanently");	header("Location:http://www.x.com/you_10");	exit();}
Copy after login
Copy after login

if($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']=='www.x.com/you_10_1'){	header("HTTP/1.1 301 Moved Permanently");	header("Location:http://www.x.com/you_10");	exit();}
Copy after login
Copy after login


不好意思,这样的应该对我不适用,我是用的php框架,这样会导致“重定向循环”

apache下实现301永久性重定向的方法

apache下实现301永久性重定向的方法



具体的RewriteCond、RewriteRule我不知道怎么写

请教一下,谢谢

你是要用PHP来实现还是web服务器来实现?


用apache实现,请问怎么实现?我就是不会写RewriteCond、RewriteRule

求指教!

框架有自己的rewrite,直接??有?突,需要你?在框架的rewrite之前。

<IfModule rewrite_module>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^you_10$ http://www.x.com/you_10_1 [R=301,L]</IfModule>
Copy after login
Copy after login
Copy after login
Copy after login

框架有自己的rewrite,直接??有?突,需要你?在框架的rewrite之前。

<IfModule rewrite_module>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^you_10$ http://www.x.com/you_10_1 [R=301,L]</IfModule>
Copy after login
Copy after login
Copy after login
Copy after login


分数给你了。

框架有自己的rewrite,直接??有?突,需要你?在框架的rewrite之前。

<IfModule rewrite_module>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^you_10$ http://www.x.com/you_10_1 [R=301,L]</IfModule>
Copy after login
Copy after login
Copy after login
Copy after login


先谢谢你一下!

我想再请问一个问题:之前的网址url都是以 _ 作为分隔号:如: www.x.com/yo_1_1_1
但是现在已经都改为以 / 为分隔号的url 如 :www.x.com/yo/1/1/1

现在需要将之前以 / 的url 全部定向到 以 / 分隔的url

请问怎么办呀


框架有自己的rewrite,直接??有?突,需要你?在框架的rewrite之前。

<IfModule rewrite_module>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^you_10$ http://www.x.com/you_10_1 [R=301,L]</IfModule>
Copy after login
Copy after login
Copy after login
Copy after login


先谢谢你一下!

我想再请问一个问题:之前的网址url都是以 _ 作为分隔号:如: www.x.com/yo_1_1_1
但是现在已经都改为以 / 为分隔号的url 如  :www.x.com/yo/1/1/1

现在需要将之前以 / 的url 全部定向到 以 / 分隔的url 

请问怎么办呀

????是在框架的路由?中修改的。

????是在框架的路由?中修改的。



我不是问 如何实现修改 url (not 从 _ 到 / )
 而是:将旧的 url 使用301重定向到新的url。还是在服务器配置里面重定向。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue3+TS+Vite development skills: how to optimize SEO Vue3+TS+Vite development skills: how to optimize SEO Sep 10, 2023 pm 07:33 PM

Vue3+TS+Vite development skills: How to perform SEO optimization SEO (SearchEngineOptimization) refers to optimizing the structure, content and keywords of the website to rank it higher in search engines, thereby increasing the website's traffic and exposure. . In the development of modern front-end technologies such as Vue3+TS+Vite, how to optimize SEO is a very important issue. This article will introduce some Vue3+TS+Vite development techniques and methods to help

What is php domain name redirection? Summary of several methods of PHP redirection What is php domain name redirection? Summary of several methods of PHP redirection Mar 21, 2023 am 09:35 AM

PHP domain name redirection is an important network technology. It is a method of redirecting different domain names visited by users to the same main domain name. Domain name redirection can solve problems such as website SEO optimization, brand promotion, and user access, and can also prevent the abuse of malicious domain names. In this article, we will introduce the specific methods and principles of PHP domain name redirection.

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

Internet Explorer opens Edge: How to stop MS Edge redirection Internet Explorer opens Edge: How to stop MS Edge redirection Apr 14, 2023 pm 06:13 PM

It's no secret that Internet Explorer has fallen out of favor for a long time, but with the arrival of Windows 11, reality sets in. Rather than sometimes replacing IE in the future, Edge is now the default browser in Microsoft's latest operating system. For now, you can still enable Internet Explorer in Windows 11. However, IE11 (the latest version) already has an official retirement date, which is June 15, 2022, and the clock is ticking. With this in mind, you may have noticed that Internet Explorer sometimes opens Edge, and you may not like it. So why is this happening? exist

Redirect tutorial in PHP Redirect tutorial in PHP Sep 01, 2023 pm 05:53 PM

Redirects allow you to redirect client browsers to different URLs. You can use it when switching domains, changing website structure, or switching to HTTPS. In this article, I will show you how to redirect to another page using PHP. I'll explain exactly how PHP redirects work and show you what's happening behind the scenes. Learn PHP with Free Online Courses If you want to learn PHP, check out our PHP Basics free online course! PHP Basics Jeremy McPeak October 29, 2021 How do basic redirects work? Before we get into the details of PHP redirection, let’s take a quick look at how HTTP redirection actually works. Take a look at the image below. Let us understand the above screen

What is a 301/302 redirect? How to redirect the website? What is a 301/302 redirect? How to redirect the website? Jul 12, 2022 pm 12:07 PM

What is a 301/302 redirect? How to redirect the website? This article will take you through 301/302 jumps, introduce the jump methods, and analyze them from the SEO perspective to see which method is practical. I hope it will be helpful to everyone!

Summary of Vue development experience: Practice in solving SEO and search engine optimization Summary of Vue development experience: Practice in solving SEO and search engine optimization Nov 22, 2023 am 08:44 AM

Summary of Vue development experience: Practice in solving SEO and search engine optimization In the current era of rapid development of mobile Internet and Web technology, search engines are still one of the most important ways to obtain information on the Internet. For websites that need to gain high exposure in search engines, SEO (SearchEngineOptimization) is an essential task. So, for web development projects using Vue technology, how to achieve SEO and search engine optimization? Vue

How Vue performs SEO optimization and practical suggestions How Vue performs SEO optimization and practical suggestions Jun 09, 2023 pm 04:13 PM

With the continuous development of web technology, more and more websites are beginning to use Vue as the front-end framework. Although Vue can provide a good user experience and development efficiency, there are still some challenges in search engine optimization. This article will introduce how Vue performs SEO optimization and some practical suggestions. 1. Vue’s SEO issues Vue’s SEO issues mainly include the following points: Server-side rendering issues: Vue is a single-page application (SPA), which means that it is rendered in the browser through JavaScript

See all articles