Solved

Help with Modrewrite in .htaccess

Posted on 2011-09-21
2
265 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 50

Accepted Solution

by:
Steve Bink earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
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 video teaches users how to migrate an existing Wordpress website to a new domain.

760 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

18 Experts available now in Live!

Get 1:1 Help Now