Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with Modrewrite in .htaccess

Posted on 2011-09-21
2
Medium Priority
?
285 Views
Last Modified: 2012-05-12
I have created a new website for someone and I need to point a directory from the old site to the root of the new site.  I am having some problems with this and I think it is because the old directory had an apostrophe and a space in the name, for example Mike's Site.  

Here is the code that I am trying to use in the .htaccess file but with no luck.

RewriteRule ^Mike%27s%20Site(/.*)?$ /$1 [L,R=301]

Will someone help me resolve this?
0
Comment
Question by:csimmons1324
2 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 36578356
>>> I think it is because the old directory had an apostrophe and a space in the name

I'm guessing you are realizing now what an absolutely horrible idea that was.  I don't mean to kick you when you're down, but you will save yourself a lot of future heartache by learning this lesson now.

You'll need to play with the rules to find out what is and is not being picked up.  Make sure you turn on and use your RewriteLog.  Note that this has to be enabled in the server's conf file or in the VirtualHost container.  If you do not have access to turn it on, contact your hosting provider to help you out with it.

If anything in the characters is causing the issue, it is likely to be the apostrophe.  Because of differing character sets, your URL might not actually contain %27.  Try an explicit apostrophe (i.e., ^Mike's%20Site) in the file.  Also, the URL could be not matching due to a leading slash (/?Mike's%20Site).

Finally, you can try working around the punctuation using a regex wildcard.  Depending on how you form the regex, and how many similar directories you have on the server, this could be the easy way out:

RewriteRule ^/?Mike.s.Site(/.*)?$ /$1 [L,R=301]

0
 

Author Comment

by:csimmons1324
ID: 36580680
You are not kicking me when I am down.  The old site was created by someone else ;)  I am just trying to clean up a mess created by someone else.  
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

886 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