Solved

Conflict using RewriteRules

Posted on 2013-01-01
9
208 Views
Last Modified: 2013-02-04
I currently have the following .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

RewriteRule ^redirect-to/(.*)$ index.php?cID=467&to=$1 [NC,L]
</IfModule>

Open in new window


I really need the
RewriteRule ^(.*)$ index.php/$1
, as it is the base for our CMS. However, the other line, "redirect-to" does not work. If I take out the first line, needed by the CMS, it works, if I add it together with the other, it fails... 500 errors.

I think it has to do because the first is a site-wide rewrite, and redirect-to is more specific. How can I get these to work together?
0
Comment
Question by:redworks
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38734612
Have you tried putting that rule  before the other?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^redirect-to/(.*)$ index.php?cID=467&to=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

</IfModule>

Open in new window

0
 

Author Comment

by:redworks
ID: 38734614
Yes, I did. Gives me a 500 Internal Server Error.
0
 
LVL 13

Expert Comment

by:Sandy
ID: 38735775
check application option also for SEO optimization.
0
 

Author Comment

by:redworks
ID: 38741535
I did, thats not the issue. They use the .htaccess for SEO control.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
ID: 38760326
I would think that line 9 in kaufined's suggestion needs something that says "final" and does not loop. So I would test writing it as:
RewriteRule ^(.*)$ index.php/$1 [L,NC]

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38761651
@fibo

Doesn't that only matter if more rules follow the rule in question?
0
 
LVL 29

Expert Comment

by:fibo
ID: 38825751
No it does not matter if more rules follow in your script.
But it does matter if they are used or not after a previous rewrite.
The [L] says "do not go further in this file"... which in the last example I gave would go to the "new url"... which would then pass again thru the htaccess file.
So the "new url" will now go against all the rewrite rulen beginning at the top of the file.
0
 

Author Closing Comment

by:redworks
ID: 38850707
This worked, great :)
0
 
LVL 29

Expert Comment

by:fibo
ID: 38850806
B-) Glad it helped. Thx for the grade and points!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup 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

[Part 2 of a 6 part series called SEO Basics: 5 SEO Secrets for Creating Content that Drives Traffic (http://www.experts-exchange.com/Web_Development/Internet_Marketing/Search_Engine_Optimization_SEO/A_8369-SEO-Basics-5-SEO-Secrets-for-Creating-Cont…
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). #…
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 Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

911 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

21 Experts available now in Live!

Get 1:1 Help Now