?
Solved

.htaccess file redirect

Posted on 2014-09-24
11
Medium Priority
?
278 Views
Last Modified: 2014-09-26
I'm trying to redirect visitors to our site to a new site unless they are looking for the CRM subdirectory.

So far I have
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/CRM [NC]
RewriteRule (.*) http://newsite.com/ [R=301,L]

Open in new window


But it is not redirecting anything.

Any ideas?
0
Comment
Question by:hrolsons
[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
  • 5
  • 4
  • 2
11 Comments
 
LVL 15

Expert Comment

by:Insoftservice
ID: 40343466
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/CRM/
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

OR

RewriteEngine on
RewriteRule !^CRM($|/) http://example.com%{REQUEST_URI} [L,R=301]

OR

RewriteEngine On
RewriteCond %{REQUEST_URI} !/CRM
RewriteRule ^.*$ http://www.newsite.com/ [R=301]
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 40344337
I like your original rule, with a minor edit:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/?CRM [NC]
RewriteRule /?(.*) http://newsite.com/$1 [R=301,L]

Open in new window

However, your existing rule should already be redirecting.  Make sure you have .htaccess files enabled, and troubleshoot their application if necessary.  If you can prove the .htaccess is being processed, try turning on the RewriteLog (instructions for 2.2 or 2.4).  Once you have the log reporting, paste the results of a single request which should have been directed, and we can assist.
0
 

Author Comment

by:hrolsons
ID: 40344674
Thank You "Steve Bink".  Through your link I was able to change httpd.conf and have "AllowOverride All".  Problem now is that it's not leaving the "CRM" directory alone.  When trying to access www.mysite.com/CRM I get an "Internal Server Error".
0
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 
LVL 51

Expert Comment

by:Steve Bink
ID: 40344758
If you disable the Rewrite* set, do you still get the error?  If you disable the "AllowOverride" directive, do you still get the error?

You do not need to use "AllowOverride All" for the purposes of rewrite.   You only need the "FileInfo" group to allow rewrites to work.  It may be that allowing all overrides may be impacting other aspects of your CRM application.
0
 

Author Comment

by:hrolsons
ID: 40344786
I added this to httpd.conf and things seem to be working as expected now.  Hopefully I've not opened up a security hole.

<Directory "/usr/local/www/vhosts/mysite.com/html/CRM/">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Open in new window

0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 40344862
Glad you got it to work.  Is there is an .htaccess file inside the /CRM directory?
0
 

Author Comment

by:hrolsons
ID: 40344881
There is not.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 40345010
Hrrmm...I'm curious what broke /CRM when you added the rule and AllowOverride.  In any case, it's working now, so probably best to adhere to the "not broken" principle.  :)

Good luck!
0
 

Author Comment

by:hrolsons
ID: 40345031
I was wrong.  There was an .htaccess file in there.  I forgot that I put one in a few weeks ago.
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 40345382
@hrolsons what was wrong in my answer.
Did you tried any of my answer
0
 

Author Comment

by:hrolsons
ID: 40346520
I'm sorry @insoftservice I did try your suggestions but due to the httpd.conf file it wasn't allowing the .htaccess file to execute no matter what was in there.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

718 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