Solved

Help with Modrewrite in .htaccess

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

740 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