Forum Moderators: phranque

Message Too Old, No Replies

RSS Feeds for Joomla

I'm still not quite there with rewrite rules

         

BillyS

8:18 pm on Feb 4, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've spent the last week upgrading an exising Joomla 1.0 site to 1.5 (yes, I know it's out of support in April...).

Anyway, I've everything up and running on a new server (with modern software too), and I'm chasing down the last of the 404's. The problem I'm having is with legacy RSS feeds. I've at least a dozen and I don't think it's efficent to keep chasing each one.

Right now, I have (to address the various forms):

RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=option=com_rss&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=0$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS1.0&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&amp%25253bfeed=RSS2.0&amp%25253bno_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=1$
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

I've done some reading (about 2 hours worth) and I know I can use NC in the above too...

Two questions:

Could the above conditions simply be written as?:

RewriteCond %{QUERY_STRING} ^option=com_rss(.+)$

I also saw warning by g1smd that if:

RewriteCond %{THE_REQUEST}

Wasn't in the statement, the above could loop. I know that g1smd has also done a lot with Joomla's .htaccess and I'd like to optimize the order too.

I've included the above as the first set of rewrite rules, next in order include:

# Begin - Redirect index.php to /
# Begin - Redirect non-www to www
# Begin - Common Exploits
# Begin - Joomla! core SEF Section

As always, anyone's help is very much appreciated.

Bill

BillyS

12:52 pm on Feb 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Reading a recent post of g1smd, and looking back at the Joomla .htaccess file, I see the recommended order looks like it should be:

# Begin - Common Exploits
# Begin - Redirect index.php to /
# Begin - Redirect non-www to www
# Begin - Common Exploits
# Begin - Joomla! core SEF Section

Going back to one of the other questions, as I've found a second solution to this code:

RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=option=com_rss&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=0$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS1.0&no_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&amp%25253bfeed=RSS2.0&amp%25253bno_html=1$ [OR]
RewriteCond %{QUERY_STRING} ^option=com_rss&feed=RSS2.0&no_html=1$
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

Option 1:
RewriteCond %{QUERY_STRING} ^option=com_rss(.+)$
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

Option 2:
RewriteCond %{QUERY_STRING} ^(.*&)?option=com_rss(&.*?$ [NC]
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]



Option 3:
RewriteCond %{QUERY_STRING} ^/index.php?option=com_rss(.*) [NC]
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]


The other question about this is remains too:

I also saw warning by g1smd that if:

RewriteCond %{THE_REQUEST}

I think it was Lucy24 that pointed to a site where regular expressions was explained (university of virginia). I never understood what this was doing until I read that post. The question above really has to do with the explanatino of wildcards, which I still have yet to find a good explanation.

I've disabled smiles, but in preview it looks like it might post in the above so I placed it in "code."

Again, thanks in advance with the above. I don't know what happened to Jim, his last post was about 7 months ago. Looks like g1smd and Lucy 24 have been holding down the fort. (I do hope nothing is wrong with Jim if I missed it, apologies to all).

Bill

lucy24

10:30 pm on Feb 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



jd is apparently plagued by what one of my other forums likes to call Real Life. He swings by now and then just to assure us that the report of his demise is an exaggeration.

Do you want to
#1 dump all query strings that contain the option=com_rss{blahblah} component,
OR
#2 dump that component while keeping the rest of the query?

Both options are pretty easy but they're handled in different ways.

For option 1, a single Condition will do it. No anchors:

RewriteCond %{QUERY_STRING} option=com_rss
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

will simply dump the entire query string. Add details if there are some option=com_rss queries you want to keep and others you want to dump.

For option 2, you can do it in mod_rewrite but there's a much easier way. Tell your php script to ignore this item, and tell GWT and related entities the same thing. And then let that particular query die a natural death.

%{THE_REQUEST} means what the user's browser originally asked for. That includes Redirects (whether by mod_rewrite, mod_alias, mod_dir or other means) but not Rewrites. It's crucial any time you're doing the redirect-to-rewrite two-step, where you have a pretty URL serving content from an unpretty php script. Without the REQUEST condition you will go around and around in circles until the server puts its foot down and delivers a 403.

Disabling Smileys is unnerving, because it seems not to work in Preview. But as you can now see, it does work in the real post. There are similar weirdnesses involving formatting tags like "pre" or "fixed" that look different in Preview. And let's not even talk about what happens with non-ASCII text.

Oh, yes, and if g1 says anything about joomla's htaccess, listen to him ;)

BillyS

4:08 am on Feb 6, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Lucy24, thanks for the response I just got back from watching my favorite team win the Super Bowl.

I want to take any query that has option_rss and send it to the same spot. As I was reading, I can accross a suggestion like your solution:

RewriteCond %{QUERY_STRING} option=com_rss
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

In case someone actually comes across this example, I'm thinking the total solution to the above is something like this:

RewriteCond %{QUERY_STRING} option=com_rss [NC, OR]
RewriteCond %{QUERY_STRING} option=option=com_rss [NC]
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]

I read what you said about RewriteCond %{THE_REQUEST} about five times, where you distiguish between a rewrite and a redirect. I don't think that applies in this situation because I'm not doing redirecting before this rewrite.

I'll change the .htaccess tomorrow when I can watch what happens afterwards (never a good idea to change something then go to sleep).

I'll keep watching this thread in the even g1smd weighs in.

Thanks again,

Bill

BillyS

11:31 pm on Feb 6, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I was about to start testing the above, I just realized this is sufficient:

RewriteCond %{QUERY_STRING} option=com_rss [NC]
RewriteRule ^index2\.php$ /rss.feed? [R=301,L]