Forum Moderators: phranque
/dir1/language/1290.php
We want to redirect 14900 records to a new domain
[newdomain.com...] and issue a 301 permanent redirect. (Last week we made a search and noted that our pages are showing up on keyword searches which we held until recently at Google and AJ.
The file 1290.php is an example and the records end at 14900.
I am using many permanen redirects and I recently saw that a solution was posted to it. Last night I searched and browsed WW for around two hours but I could find the post.
Can someone please point me to the right thread.
Thanks
Asinah
It should be any number <any_number>.php but the directory on the remote server has a different name and it should generate the 301 redirect so that google and the other SE's would find the new pages. We don't want to redirect all pages to the new server and only the pages in /dir1/. The other directories would not be affected.
example :
/dir1/<any_number>.php to [newserver.com...]
I am sure it was discussed last week but I have searched for some times on this forum with google without success.
If you can point me to the right thread I would be very grateful.
All you need to do is redirect all files in that one directory that match the <any_number>.php pattern to another domain. As such, look for "permanent redirect domain rewriterule [google.com]". Post your best effort at writing the code and your test results, and we'll help you get it working if you have problems.
Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]
Jim
RewriteEngine on
RewriteBase /dir1/
rewriterule ^dir2/(.+).html [newserver.com...] [L,R=301]
I think my problem is in the rewritrule but I will keep trying and learning.
RewriteRule ^dir2/([0-9]{1,5})\.html$ http://www.newserver.com/dir2/$1 [L,R=301]
Jim
Can you tell me Jim if this code would work?
RewriteRule ^dir/([0-9]{1,5})\.php$ [newserver.com...] [L,R=301]
Currently the files reside on an old server at
htt://oldserver.com/dir/*.php and all files will be redirected to htt://oldserver.com/dir2/*.html
/dir and /dir2 are different names
I really appreciate your feedback.
Doesn't work: [newdomain.com...]
This does work
[newdomain.com...] (English is the default language) but as soon I am going into the 2nd level directory it shows a mysql error.
eg..
[newdomain.com...]
Do I need to set a base directory? On the new domain I don't use the structure of dir2/language but only use dir2/
I ahd to disable the modifications as the 6 languages are down for the momwent.
Problems like this are most easily discussed if you include a comprehensive list of all needed rewrites from the start.
Right now we have:
/dir/0.php$ ------> [newserver.com...]
/dir/99999.php$ --> [newserver.com...]
What else is needed to include 'language' URLs?
Jim
/dir/0.php$ --> [newserver.com...]
/dir/99999.php$ --> [newserver.com...]
The above works already for the english version.
We have the following directories inside /dir
/dir/chinese/99999.php$ --> [newserver1.com...]
/dir/deutsch/99999.php$ --> [newserver2.com...]
/dir/japanese/99999.php$ --> [newserver3.com...]
/dir/french/99999.php$ --> [newserver4.com...]
/dir/italiano/99999.php$ --> [newserver5.com...]
/dir/espaniol/99999.php$ --> [newserver6.com...]
Do I need to set a base directory as the old structure is different from the new site structure?
Asinah
However, the solution with your current directory structure would simply be one rule for each language:
RewriteRule ^dir/([0-9]{1,5})\.php$ http://www.newserver.com/dir2/$1\.html [L,R=301]
RewriteRule ^dir/chinese/([0-9]{1,5})\.php$ http://www.newserver.com/dir3/$1\.html [L,R=301]
RewriteRule ^dir/deutch/([0-9]{1,5})\.php$ http://www.newserver.com/dir4/$1\.html [L,R=301]
RewriteRule ^dir/japanese/([0-9]{1,5})\.php$ http://www.newserver.com/dir5/$1\.html [L,R=301]
RewriteRule ^dir/french/([0-9]{1,5})\.php$ http://www.newserver.com/dir6/$1\.html [L,R=301]
RewriteRule ^dir/italiano/([0-9]{1,5})\.php$ http://www.newserver.com/dir7/$1\.html [L,R=301]
RewriteRule ^dir/espaniol/([0-9]{1,5})\.php$ http://www.newserver.com/dir8/$1\.html [L,R=301]
And just for reference, the solution using the two-letter method would be:
RewriteRule ^dir/([0-9]{1,5})\.php$ http://www.newserver.com/dir2/$1\.html [L,R=301]
RewriteRule ^dir/([a-z]{2})[^/]+/([0-9]{1,5})\.php$ http://www.newserver.com/$1/$2\.html [L,R=301]
I never use RewriteBase unless I can't get the code to work without it, and then I simply review the Apache error log to see what I need to include in RewriteBase. The error log will indicate where the server attempted to fetch the resource from, and comparing that to where it actually resides on the server will give the necessary RewriteBase path.
Jim