| Author |
Message |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 4824
|
Posted:
Wed Mar 05, 2008 9:54 am |
|
I know this is going to be really simple buy I just cannot see the wood for the tree's....
I have a script which outputs a url;
| Code: | | /reviewer_about/Guardian.php? |
The link is formulated from the construct
| Code: | | /reviewer_about/$username2.php? |
The current re-write rule is;
| Code: | | RewriteRule ^reviewer_about/([^/])\.php reviewer_about.php?username=$username2 [QSA,L] |
The correctly re-written link should be in the form of
| Code: | | /reviewer_about.php?username=Guardian |
Anyone have any idea's where the re-write rule is failing or why?
Personally I don't think it's worth bothering re-writing this but that is how the original author has done it and it will save me recoding about 20 files if anyone can help. |
|
|
|
 |
Raven Site Admin/Owner

Joined: Aug 27, 2002 Posts: 15221 Location: Kansas
|
Posted:
Wed Mar 05, 2008 3:58 pm |
|
Have you tried turning the log level on to see exactly where the rule is going wrong? This can't be done in .htaccess. It must be done in httpd.conf.
Add these two directives to your httpd.conf immediately after RewriteEngine On
#
# name it whatever you want
#
RewriteLog “/some_path/rewrite_log”
#
# can be 0-9. The higher the number the more verbose
#
RewriteLogLevel 3 |
|
|
|
 |
montego Site Admin

Joined: Aug 29, 2004 Posts: 7459 Location: Arizona
|
Posted:
Wed Mar 05, 2008 6:37 pm |
|
Guardian, I am not sure what QSA is, but that rewrite rule does not look right to me. Does the following work?
RewriteRule ^reviewer_about/([^/.]*)\.php reviewer_about.php?username=$1 [QSA,L]
I won't really like how open that is, so if you had restrictions on user names, you might want to restrict that rule a bit.
Edited: I also added in the "." in-between the []. If it causes issues, take it out. |
|
|
|
 |
montego Site Admin

Joined: Aug 29, 2004 Posts: 7459 Location: Arizona
|
Posted:
Wed Mar 05, 2008 6:40 pm |
|
Just looked up QSA. Sorry... should have done that previously. My question to you is do you really need it? If you take the "QSA," out of my rule, doesn't it work? |
|
|
|
 |
Guardian2003 Site Admin

Joined: Aug 28, 2003 Posts: 4824
|
Posted:
Thu Mar 06, 2008 12:48 am |
|
Thanks for the info guys, I'll be checking all this out as soon as I have woken up properly.
M you could be right about not needing QSA, I think someone just got hold of the fact that "it will append any variable between a pattern match to the end of the url" and went with it instead of looking deeper.
The username is restricted to alpha-numeric.
I can see how QSA might be useful in nuke as an example if you wanted to pass $title or something with useful SEO content to the end of a url (food for thought?) but this thing only passes the username and for other stuff an integer is used so the usefulness for SEO is questionable in my eyes. |
|
|
|
 |
|
|
|
|