Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conflict using RewriteRules

Posted on 2013-01-01
9
Medium Priority
?
214 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:redworks
ID: 38741535
I did, thats not the issue. They use the .htaccess for SEO control.
0
 
LVL 29

Accepted Solution

by:
fibo earned 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Wondering how you can get your new website ranking on Google Search so that people find you online?  The answer is Search Engine Optimization (SEO). So how do you Start Ranking a New site with SEO?  Below is a starter guide to get your new website S…
Online promotion is consistently becoming more important for all types of businesses. From Facebook ads to search engines to YouTube videos, there are all sorts of channels that can effectively be used to promote a business or product. But how shoul…
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.
Suggested Courses

715 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