Solved

Help with Modrewrite in .htaccess

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 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