Php URL to jump old directory to new directory

Source: Internet
Author: User
A website about mobile phone, with WordPress base board.
The original htacess is placed in the main directory/var/www/html
 
  
   
  Rewriteengine onrewritebase/rewriterule ^items/products/(\d+)/(. *)? $ items/products.php?number=$1&name=$2 [QSA , L]rewritecond%{request_filename}!-frewritecond%{request_filename}!-drewriterule. /index.php [L]
 
  

Create a new. Htacess in sub-directory '/var/www/html/2014
 
  
   
  Rewriteengine onrewritebase/2014/rewriterule ^phone/products/(\d+)/(. *)? $ phone/products.php?number=$1&name=$ 2 [Qsa,l]rewritecond%{request_filename}!-drewritecond%{request_filename}!-frewriterule (. *) $1.php [L]
 
  


Now you want to permanently redirect the old URL address to the new URL.
www.example.com/items/products/1234/iphone-5c
=
www.example.com/2014/phone/products/1234/iphone-5c


I'm trying to fix the source code in items/products.php.
 
  

Unexpectedly error Request exceeded the limit of internal redirects due to probable configuration error. Use ' limitinternalrecursion ' to increase the limit if necessary. Use the ' LogLevel debug ' to get a backtrace.

Change the source code back to the original, add echo ' http://www.example.com/2014/phone/products/'. $_get[' number '. ' /'. $_get[' name '];
Page normal display http://www.example.com/2014/phone/products/1234/iphone-5c, the mouse right-click to open the URL in a new window, you can normally jump, but why the Apache return error?

And then try to modify

And then the htacess in the main directory.
Rewriterule ^item/products/(\d+)/(. *)? $ items/products.php?number=$1&name=$2 [qsa,l]
Become
Rewriterule ^2014/phone/products/(\d+)/(. *)? $ items/products.php?number=$1&name=$2 [QSA,L,R=301]

This time unexpectedly jump to wordpress 404 page.

Depressed, in the end how to do, to normal jump?


Reply to discussion (solution)

1) Header jump error, the wrong wording. Header ("Location: $url");
In addition the inside of the $_get these few if not exist, and did not set the error level, then still easy to error

2) rewrite the file. htaccess do not need to be placed in the/2014/directory, directly in the original/rewrite can

#by default7#zbphp.com
 
  
   
  rewriteengine onrewritecond%{request_filename}!-drewritecond%{REQUEST_ FILENAME}!-frewriterule ^items/products/(\d+)/(. +)? $  2014/phone/products/$1/$2/  [l,r=301]rewriterule ^ 2014/phone/products/(\d+)/(. +)? $ phone/products.php?number=$1&name=$2 [Pt,qsa,l]rewriterule (. *) $1.php [L]
 
  
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.