Solved

Conflict using RewriteRules

Posted on 2013-01-01
9
207 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 74

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 74

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

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

Suggested Solutions

Title # Comments Views Activity
MDB2 Error: not found 4 135
browser caching 4 57
Setting up a WAMP server... 7 51
.htaccess file settings 4 37
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
[Part 6 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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now