Solved

.htaccess file exclusion

Posted on 2014-09-30
12
122 Views
Last Modified: 2014-10-01
I have an .htaccess file that is working great:
RedirectMatch 301 (.*)\.html$ http://newsite.com

Open in new window

How could I exclude the directory "http://newsite.com/Intranet/" from the redirect?
0
Comment
Question by:hrolsons
  • 7
  • 5
12 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40353228
RewriteCond %{REQUEST_URI} !^/intranet/ [OR]
RewriteCond %{REQUEST_URI} ^.html
RewriteRule (.*) http://newsite.com/ [L,R=301]

Open in new window

0
 

Author Comment

by:hrolsons
ID: 40353234
@Gary, do I put those 2 lines after my line OR instead of my line?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40353235
Instead of (I just made an amendment to it before you posted)
0
 

Author Comment

by:hrolsons
ID: 40353282
Doesn't seem to be working.  For instance, http://originalsite.com does not redirect and http://originalsite.com/Intranet/ does redirect to http://newsite.com
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40353355
RewriteCond %{REQUEST_URI} !^/intranet
RewriteCond %{REQUEST_FILENAME} .*\.html$
RewriteRule . http://testsite.com [L]

Open in new window

0
 

Author Comment

by:hrolsons
ID: 40355020
Same exact results.  I wonder what's up?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 58

Expert Comment

by:Gary
ID: 40355030
I tried it locally and it works fine.
Give me some test url's
0
 
LVL 58

Expert Comment

by:Gary
ID: 40355137
Can you post your htaccess as you have it now.
0
 

Author Comment

by:hrolsons
ID: 40355188
#RewriteEngine on
#RewriteCond %{REQUEST_URI} !^/CRM [NC]
#RedirectMatch 301 (.*)\.html$ http://originalsite.com
#RewriteCond %{REQUEST_URI} !^/ebay [NC]
#RewriteRule .* http://originalsite.com/ [R=301,L]
#RewriteCond %{REQUEST_URI} !^/Intranet/ [OR]
#RewriteCond %{REQUEST_URI} ^.html
#RewriteRule (.*) http://originalsite.com/ [L,R=301]

RewriteCond %{REQUEST_URI} !^/Intranet
RewriteCond %{REQUEST_FILENAME} .*\.html$
RewriteRule . http://originalsite.com [L]
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 500 total points
ID: 40355192
You've commented out this line

#RewriteEngine on
^
0
 

Author Comment

by:hrolsons
ID: 40355221
OK, now we're moving in the right direction.  Same problem as original though, when I go to the original site, such as :

http://www.originalsite.com/Intranet

It goes to blueappleproperties.com.  I did make sure the "I" was capitalized.
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 500 total points
ID: 40355232
You can ignore case by changing to

RewriteCond %{REQUEST_URI} !^/intranet [NC]

But I'm confused, when I go to this page I get a 404 - so it is not redirecting which I assume is correct
http://www.originalsite.com/intranet/

Edit
Actually with the capital I - I get the login form, you may need to clear your browser cache, especially if it is FF
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

22 Experts available now in Live!

Get 1:1 Help Now