Solved

Rewrite a portion of URL

Posted on 2013-06-07
3
252 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Block sender e-mail address in Postfix 4 66
.htaccess file settings 4 55
Fixing Non-Standard characters in text 8 91
Linux  Script File Attributes 5 53
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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.

910 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

19 Experts available now in Live!

Get 1:1 Help Now