Solved

Rewrite a portion of URL

Posted on 2013-06-07
3
251 Views
Last Modified: 2013-06-17
I need help rewriting a URL, please.
Here are 3 examples of the wrong URL.  I think I have 10 being indexed by google, and I would like them to point to the correct location.

/twitter.com/blogpublic.php
/twitter.com/boyandgirls.php
/twitter.com/band.php

I need them to redirect to these paths (and up to 10 variations of the ending).
http://www.mydomain.com/blogpublic.php
http://www.mydomain.com/boyandgirls.php
http://www.mydomain.com/band.php

Please note I already have code like this in .htaccss, which works for me
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ view_profile.php?mem_id=$1

# Make all requests have the www. in them
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

Open in new window


I also have this code which is working well for me too, in .htaccss

#  http://www.seomoz.org/learn-seo/redirection
#  http://perishablepress.com/case-insensitive-redirectmatch/

#  http://www.mydomain.com/view_profile.php/WWW.MYsPACE.COM/view_profile.php?mem_id=95201
#  http://www.mydomain.com/view_profile.php/WWW.MYsPACE.COM/shared_layouts.php?mem_id=95201
#  http://www.mydomain.com/view_profile.php/WWW.mYSpACE.cOM/shared_videos.php?mem_id=95201
#  http://www.mydomain.com/view_profile.php/WWw.MySPACE.COM/send_message.php?mem_id=95201
RedirectMatch 301 (?i)/view_profile.php/WWW.MYSPACE.COM/(.*)       http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/MYSPACE.COM/(.*)           http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/www.facebook.com/(.*)      http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/facebook.com/(.*)          http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/www.vampirefreaks.com/(.*) http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/vampirefreaks.com/(.*)     http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/www.twitter.com/(.*)       http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/twitter.com/(.*)           http://www.mydomain.com/$1
RedirectMatch 301 (?i)/view_profile.php/www....com/(.*)            http://www.mydomain.com/$1

#  http://www.mydomain.com/view_profile.php/kyhlgoesboom.tumblr.com/rank_band.php
RedirectMatch 301 (?i)/view_profile.php/kyhlgoesboom.tumblr.com/(.*) http://www.mydomain.com/$1

#  http://www.mydomain.com/view_profile.php/subscribe_blog.php
#  http://www.mydomain.com/view_profile.php/block_user.php
#  http://www.mydomain.com/view_profile.php/view_mem_blog.php
RedirectMatch 301 (?i)/view_profile.php/(.*)       http://www.mydomain.com/$1

#  http://www.mydomain.com/statusnotifications.php/login.php
RedirectMatch 301 (?i)/statusnotifications.php/login.php  http://www.mydomain.com/statusnotifications.php

Open in new window


The key is that /twitter.com/ seems be incorrectly inserted in my path and I need to redirect to the correct path.

Thank you.
0
Comment
Question by:U_S_A
  • 2
3 Comments
 
LVL 26

Expert Comment

by:skullnobrains
ID: 39231134
you do not seem to be asking a question there

can you please try and be explicit regarding what you expect and what actually happens ?
0
 

Author Comment

by:U_S_A
ID: 39231202
0
 
LVL 26

Accepted Solution

by:
skullnobrains earned 500 total points
ID: 39231229
RewriteRule http://www.mydomain.com/twitter.com/(blogpublic.php|boyandgirls.php|band.php) http://www.mydomain.com/$1

or rather

RewriteRule /twitter.com/(.*) /$1

this should work also using redirectmatch

if you need more help, try and state
- this is what i type in my browser
- this is where i expect to be redirected
- this is where i end up

do the other redirections work ?
what shows in the log ? did you activate the rewrite log ? verbose ?
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now