intelligencia.urlrewriter: bad request error - url-rewriting

I want to implement url rewriting with intelligencia.urlrewriter.problem is when clean URL Contains special characters such as % : * & and more.in this case I get a bad request,because the cleaned url does not contain ? sign. I work with .net 3.5 .
Is there a solution for this problem?
thanks friends

Related

Mediawiki: Pages with & and + in Name not working

I discovered a bug in my mediawiki.
When I try to open a page with a + or a & in the name, it end up in a "The Site can't be reached"-Error. In the logs i can see, that i get a high number of HTTP 301 Codes when reaching such a Page. It also translates the characters:
+ into %2B
& into %26
But is does seem like it's not getting translated back? I'm also not using any mod_rewrite Code, well atleast none that I know of.
https://www.mediawiki.org/wiki/Manual%3aShort_URL#URL_like_-_example.com.2FPage_title
This describes my Problem (under Troubleshooting), but / works fine. But as I mentiond, I don't use any URL rewriting.
I would appreciate some help, thanks :)
Edit: I've just tested some more characters that are legal for pagetitles, seems like = isn't working either.
It's translated from = into %3D

Express JS : rewrite url look like /article_name-id.html

I'm building the new version of a website and I have to take charge of older urls looks like :
http://website.com/article_title_rewrited-article_id.html
Actually, I try to work about something like that :
app.get('/:title\-:id([0-9]).html', function...);
But of course it fails !
Can I do this type of rewriting using expressjs, or have I to use another method to port the url rewriting ?
Thanks by advance !
I see you are trying to use the Express url route parser as well as REGEX expressions, unfortunately this doesn't work, you have to use one or the other.
Remove the string and place with a REGEX pattern. Then the groups in the REGEX expressions will be available at req.params[0] and req.params[1].
app.get(/(.+)\.html/, function(req, res, next) {
res.redirect(req.params[0].substring(0, req.params[0].length - 5)); // -5 for length of '.html'
});
I believe that should (untested) sort it generically for all .html extensions if that can be a helpful guide :)

How to use wild cards in FT search

I have the following:
tmpArray[cTerms++] = "[sclenka] CONTAINS \"*" + sessionScope.sclenka +"*\"";
(With the help of Per Henrik Lausten)
Which should result in: "*term*"
But it doesn't, I get this instead: "term"
So, my question is how do I use wildcard full text search?
Thank you!
If you want to use a wildcard search, then generate the following query string:
tmpArray[cTerms++] = "[sclenka] = \"*" + sessionScope.sclenka +"*\"";
This should generate a search on "*search query*".
In general, this is a good way of performing a search since the user probably expect your search to work like that.
Source: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Searching_for_Documents#Full-text+Search
If your string is correct and you are getting no results, then test the same string in the Notes client FTI search.
You can also use the following debug on the server.
DEBUG_FTV_SEARCH=1
Then check the output on the domino console when you do a search.
So if I understand you, the result is an escaped form of the search term in which the asterisks have been removed?
Could you use the construct:
tmpArray[cTerms++] = "[sclenka] CONTAINS \"" + String.fromCharCode(42) + sessionScope.sclenka + String.fromCharCode(42) + "\"";
At least that should avoid escaping?
I think you have missed a bit of escaping characters in the String you are generating.
tmpArray[cTerms++] = "[sclenka] CONTAINS \"" + sessionScope.sclenka +"\"";
leyrer, is it possible -- just possible -- that you're doing this in a browser and your session is not authenticated? If so, you may be searching the database as "anonymous" where when you test from the browser you're searching as "leyrer".
It's just a thought - but I used to see that all the time when people would start using my NCT Search tools. They'd swear they were getting no results, and when I'd dig I'd always find that they were using the browser as anonymous rather than as a logged in session.
#GKIDD
I just tested this on my own site. I have NCTSearch setup. I accepts the search term from the the web and runs database.ftsearch() as part of its job from within lotuscript.
I searched on "data*" and got at least as many results as when I searched on "database".
Based on that, I think something else is going on.
From my earlier comment on other answer, try this: Create another agent that does JUST the search. Have it grab the search term from agent context as if it were a docid. Call the agent from the first agent using "agent.runonserver(searchterm)" see if you can fool it
Andrew, I'm getting the results with Anonymous user, but not with the wildcard. Here goo.gl/YVtXm on the first line, it says that CONTAINS or contains or = does not work when searching from the web.

htaccess - Rewrite to capture friendly URL or querystring

I'm trying to come up with one or more rewrite rules that will take either a friendly url or a url containing the full query string.
The plan is to create a text-only page by reading in the URL using PHP's loadHTML.
For example:
Input
1. http://www.example.com/disclaimer (http://www.example.com/text/disclaimer on text-only version)
2. http://www.example.com/info/aboutus (http://www.example.com/text/info/aboutus on text-only version)
3. http://www.example.com/news?id=123 (http://www.example.com/text/news?id=123 on text-only version)
Output
1. http://www.example.com/includes/textonly.php?page=disclaimer
2. http://www.example.com/includes/textonly.php?page=info/aboutus
3. http://www.example.com/includes/textonly.php?news?id=123
So on the textonly.php I would use $_GET['page']); for example 1) and 2), and use $_SERVER['QUERY_STRING']; for example 3).
For example 1) and 2), I came up with:
RewriteRule ^text/(.*) includes/textonly.php?page=$1
And for example 3), I came up with:
RewriteRule ^text/(.[?]) /includes/textonly.php [QSA]
They work independantly but not together. Can anyone help?
With guidance from Tom and Michael, this is what I've come up with:
in Htaccess send everything to PHP in the querystring:
RewriteRule ^text/(.*) /includes/textonly.php [QSA,L]
Then in PHP:
$page = 'http://'.$_SERVER['HTTP_HOST'].'/'.str_replace('/text/','',$_SERVER['REQUEST_URI']);
Seems to work for both friendly urls (2 levels deep tested so far) and querystrings.
Hopefully its okay, so I'll go with this as a solution :)
I suggest handing control over to PHP - I wrote an article on this a while ago - http://tomsbigbox.com/elegant-url-rewriting/ - it details how to send the query string to a PHP file that then decides what to do - so if the page exists for example it will load it, otherwise do something else.
I've found that to be the best solution to URL rewriting.
I'd change your rewrite rule to look like this:
RewriteRule ^([^/\.]+)/?([^/\.]+)?/?$ /includes/textonly.php?page=$1&id=$2 [L,NC]
Then slightly modify your Input URLs to look like this:
1. http://www.example.com/disclaimer
2. http://www.example.com/info/aboutus
3. http://www.example.com/news/123
And they would point to these URLs:
1. http://www.example.com/includes/textonly.php?page=disclaimer&id=
2. http://www.example.com/includes/textonly.php?page=info&id=aboutus
3. http://www.example.com/includes/textonly.php?page=news&id=123
The regex above will match anything between the /, not including a / or a .. The second half is optional, so in that rule, you could only go two directories deep.
Controlling all three URLs in the same way will make your logic a little cleaner on the textonly.php page as you do not need to write special logic for the first two URLs compared to the last.

mod_rewrite newbie needs help with (simple?) rewrite rule

I tried. I failed. Here's what I want to do:
Using firebug I saw that the GET string in the request header for my stylesheets and other content was being munged by the application (which I can't modify). I think a simple rewrite rule might help but I can't get it to work. Here's what I need:
input: /content/2010/08/forum/styles/xyz/theme/normal.css
output: /forum/styles/xyz/theme/normal.css
input: /content/forum/styles/xyz/template/blah.js
output /forum/styles/xyz/template/blah.js
input: /content/my-own-page/forum/happy.htm
output: /forum/happy.htm
So, whatever comes in IF it contains "forum/" then get rid of what precedes "forum/" and return everything from "forum/", foward.
Something along these lines should probably do the job.
RewriteRule ^.*/forum/(.*)$ /forum/$1

Resources