?
Solved

Rewrite a portion of URL

Posted on 2013-06-07
3
Medium Priority
?
267 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 27

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
How do I redirect requests for http://www.mydomain.com/twitter.com/blogpublic.php to http://www.mydomain.com/blogpublic.php 

How do I redirect requests for http://www.mydomain.com/twitter.com/boyandgirls.php to http://www.mydomain.com/boyandgirls.php 

How do I redirect requests for http://www.mydomain.com/twitter.com/band.php to http://www.mydomain.com/band.php
0
 
LVL 27

Accepted Solution

by:
skullnobrains earned 2000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

809 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