?
Solved

Help with Modrewrite in .htaccess

Posted on 2011-09-21
2
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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

719 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