Mod Rewrite Clarification

I am trying to get some url's that have linked to our site redirected.

They come in like this:
http://www.domain.com/tlp/index.php?topic=10.0 or http://www.domain.com/tlp/index.php?board=5.0

Instead I need them to be http://www.domain.com/tlp/index.php/topic,10.0.html

Here is what I have come up with but it isn't pattern matching.  Can someone tell me why this isn't working and what it needs to be changed to?

RewriteCond %{REQUEST_URI} tlp/index\.php [NC]
RewriteCond %{QUERY_STRING} (topic|board)=([0-9]+)\.([0-9]+)
RewriteRule ^.+$ /tlp/index.php/$1,$2.$3.html? [R=301,L]


Thanks,

Randal
sharingsunshineAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Use the percent sign ( % ) when referring to backreferences from the RewriteCond:
RewriteRule ^.+$ /tlp/index.php/%1,%2.%3.html? [R=301,L]

Open in new window

0
sharingsunshineAuthor Commented:
I changed the backreferences but there is no change.  All of the working rewrites are using $'s.

This is what is given when the link is clicked on

http://www.domain.com/tlp/index.php%3Ftopic%3D10.0
0
käµfm³d 👽Commented:
This is my test (.htacces, before, and after):
untitled.PNG
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

käµfm³d 👽Commented:
All of the working rewrites are using $'s.
Ordinarily, yes, you use $ to refer to backreferences in RewriteRules, but to refer to backreferences in prior RewriteCond, then you use %.
0
käµfm³d 👽Commented:
0
sharingsunshineAuthor Commented:
I will pay attention to that in my other rules.  Now, to my problem do you have any more ideas?

By the way, I even moved it to be the first rule after RewriteBase /
0
käµfm³d 👽Commented:
Where are you redirected to or what error message do you receive? Also, what does the rewrite log say?
0
sharingsunshineAuthor Commented:
I checked the log and the last entry is 3//23/11

It redirects it to http://www.domain.com/tlp/index.php%3Ftopic%3D10.0
0
käµfm³d 👽Commented:
I get the feeling that you have other rules and conditions in this file. If so, is it possible they may be interfering with the rewrite? Is it possible to post such rules?
0
sharingsunshineAuthor Commented:
Yes, it is a very large .htaccess so I would need a way to send it to you offline if that is permitted?
0
käµfm³d 👽Commented:
I don't believe it violates the rules here, and if you're comfortable doing it, you can send it to send_nothing@hotmail.com. I only use this account for website sign-ups, so I don't check it. However, since I'll be expecting mail from you, you can send it. For any other questions, post back here  :)
0
sharingsunshineAuthor Commented:
Great, I sent it.  You will see I changed the domain and folder name so not everyone could see them.  The redirect in question is at line 28.

Thanks,

Randal
0
käµfm³d 👽Commented:
Is there any chance you could include it as an attachment? Everything has been pushed onto one line in HM.
0
sharingsunshineAuthor Commented:
Yes, it' sent.
0
käµfm³d 👽Commented:
As of right now, I am unable to reproduce the behavior you are seeing. I pasted in your file to my .htaccess verbatim and it appears to work fine.

Looking back over the posts, the statement

I checked the log and the last entry is 3//23/11

troubles me. Why would you not have a rewrite entry listed for these past couple of tests? Are you certain you are looking at the correct log file (rewrite.log) and is the .htaccess being put in the appropriate directory?
0
sharingsunshineAuthor Commented:
I host with hostgator and they said I had to use an ssh command to find the rewrite entries.  Here is the command they gave me

1.1.1.1 /usr/local/apache/logs/error_log | grep -i rewrite  The 1's are taking the place of my static IP that I use from my laptop.

0
käµfm³d 👽Commented:
Unless they've configured it a different way, rewrites should be in their own file (see screenshot). If they have reconfigured the server, that still doesn't explain why you aren't seeing the rewrites for these previous tests--unless your system time is a month behind!

Here's a sampling of what I see in my log when I use your .htaccess file (trimmed to rewrite messages):

strip per-dir prefix: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/smf/index.php -> smf/index.php
applying pattern '^.+$' to uri 'smf/index.php'
RewriteCond: input='/smf/index.php' pattern='smf/index\.php' [NC] => matched
RewriteCond: input='topic=34.343' pattern='(topic|board)=([0-9]+)\.([0-9]+)' => matched
rewrite 'smf/index.php' -> '/smf/index.php/topic,34.343.html?'
,34.343.html, args=<none>
explicitly forcing redirect with http://localhost/smf/index.php/topic,34.343.html
trying to replace prefix C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/ with /
escaping http://localhost/smf/index.php/topic,34.343.html for redirect
redirect to http://localhost/smf/index.php/topic,34.343.html [REDIRECT/301]
add path info postfix: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/smf/index.php -> C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/smf/index.php/topic,34.343.html
strip per-dir prefix: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/smf/index.php/topic,34.343.html -> smf/index.php/topic,34.343.html
applying pattern '^.+$' to uri 'smf/index.php/topic,34.343.html'

...

Open in new window

untitled.PNG
0
sharingsunshineAuthor Commented:
I have sent a message to the Linux Admin and will let you know.  How are you able to test the rewrites like this locally?
0
käµfm³d 👽Commented:
How are you able to test the rewrites like this locally?
I'm not sure I follow, but I demonstrated that above (http:#35337531). I have a version of Apache running on my development machine.
0
sharingsunshineAuthor Commented:
OK, I enabled a real rewrite log and I am sending it to you as a zip file.  
0
sharingsunshineAuthor Commented:
I was only asking this:

I'm not sure I follow, but I demonstrated that above (http:#35337531). I have a version of Apache running on my development machine.

Because I thought I might want to set it up on my system, like you did.  I was never questioning anything you have said.  You have been a great help.
0
käµfm³d 👽Commented:
I was never questioning anything you have said.
I didn't intend for that to come off as rude. My apologies  : )

I did receive the file. I will look at it, but it's turning out to be a busy day at work!
0
sharingsunshineAuthor Commented:
I understand and just wanted to make sure I hadn't offended you.  If you don't do anything else you have gone way above being generous.  So anything you can do will be a plus.
0
käµfm³d 👽Commented:
Hello again  : )

Can we try tacking on the "no escape" (NE) option to your rule. I believe that will take care of the encoding issue you are seeing:
RewriteRule ^.+$ /tlp/index.php/%1,%2.%3.html? [R=301,NE,L]

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sharingsunshineAuthor Commented:
0
sharingsunshineAuthor Commented:
great help overall and they put a lot of effort into helping.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.