MediaWiki query wont redirect - mediawiki

I am getting some #REDIRECT in the snippet but i actually want the query to give me the redirected results, is there a way to do that without parsing what the redirect is and initialed another query? I tried setting the parameter redirects but it did nothing.
Example:
https://en.wikipedia.org/w/api.php?format=json&action=query&list=search&srsearch=Unity3D&utf8&srlimit=10&srwhat=nearmatch&redirects
i would like it to return something like this:
https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Unity%20(game%20engine)&srlimit=1

What you can do is to use search as a generator. If you do that, redirects will work:
https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=Unity3D&utf8&gsrlimit=10&gsrwhat=nearmatch&redirects

Related

Is there a way to safely pass queries to a non-dynamic page in NextJS?

In my nextJS project I want a feature like below:
If a logged out user want to access a url that is not for a logged out user, redirect to
login page.
After user make a successful login, redirect him/her back to the
page from where he/she was redirected.
I read about some article that were describing how to use sessionStorage or localStorage to achieve this.
I am just wondering can I achieve the same using more suitable and easy way.
I tried followings:
first I tried to achieve that using document.refferer but that doesn't seem to work with nextJS.
then,
I observed some websites [including flipkart], and sent a query parameter containing the current path when redirecting to the login page. And it works fine.
But I am getting a warning from nextJS because my login page is not dynamic hence it can not have path other than /login and /login#
Is there a way to overcome this warning ? without make it like login/[queries].jsx
Any help would be appreciated. Thanks in advance..

Yii2: Rewrite URL without the help of a webserver

I would like to rewrite an URL purely using Yii2, without relying on a webserver (nginx/apache).
Example. I would like to "rewrite" a url such as [POST|PUT|GET] /v2/book/author into [POST|PUT|GET] /v2/document/author.
My first idea was to use UrlManager's $rules, but those are not really rewriting the URLs, they map URLs into routes, so as soon as the first one matches, the chain terminates.
URL rewriting needs to happen before UrlManager even begins processing the routes.
My second idea was to create a custom UrlNormalizer which simply substitutes the incoming URLs. This sounds better, but I don't know if it will work.
What is the right way to do this?
Urls are automatically created by Yii if you don't specify it.
By default <module>/<controller>/<action>/<param>
If you have a problem, where you would have to refactor the whole code for an url change, then yes, UrlManager it is. Url::to() uses your url config to adjust your <controller>/<action> identifier into an actual url. If you hardcoded the urls then you have to change the urls manually.
But you should be able to create to create a matching pattern to catch v2/book/author
I tried this in my code, and it worked:
So this should work as well

How deal with redirects in Wikipedia dump?

I have successfully imported the enwiki-latest-pages-articles-multistream.XML page into MySQL using this guide.
When I lookup the text for a page (process described here), it will often be #REDIRECT [[some_page_name]]. The only way I know of to follow this redirect is by searching through all page titles for some_page_name. Not only is this time consuming but sometimes there are multiple articles under the exact same title name!
I'm considering just removing all redirect pages from the database.
But before I do, is there a better way to handle these redirects?
As I understand, you want to determine what is the target of the redirect. Right?. If yes, then you can get it using this query:
select rd_title from redirect
inner join page
on page_id = rd_from
where page_title like "some_page_name"
The rd_title is the target page of the redirect.
Please correct me if I'm wrong.

Html Chat Or Something With Parameters

Well, I almost don't know anything about this language, so I need help!
I need codes/scripts that I can paste to my website, or copy the files on the server... then make that work.
I used to copy random ones but nothing worked.
What exactly I need:
-A chat that appears on the page
-That chat should with with URL parameters, like: www.site.com/message="Hello", so that message appears on the page
-All messages should be saved in a file on server, for example "history.txt", and that history should load by loading the page...
Is that all simple? Possible?
Thanks if anyone get me an answer(s)!
You need to use PHP to do this. If you use the GET method, parameters can be passed through the url, and it's very easy to read and write files. Where are you coding at the moment?

how to deal with www/http in href

I have a db with a buch of urls. The values were entered by users, so it might be something like www.domain.com or http://www.domain.com or stackoverflow.com or https://something.com
I'm retrieving that data and creating links in a html page so people can click and be redirected to that url.
If i get the url from the page , i'll have either:
1.<a href="www.domain.com">
or
2.<a href="http://www.domain.com">
in the second case it works, but the first it doesn't.
Is there a way to make it always work?
thanks!
The www. bit is not special at all, people rely on an automatic correction feature of most browsers to prepend it if the host does not exist. To replicate this, you need to run a program that attempts to resolve each of the host names in your database, and retries with an extra www. if that fails.
The http:// bit is easy: if it is missing, add it.
There are two ways to handle this situation:
First, validate the user input. At the time a URL is submitted, validate it (preferably on the client side via Javascript) to ensure it has the required elements.
Second, in your code, you can use a regular expression or even simple pattern matching to ensure that the string starts with 'http://' or 'https://', and prepend it as needed.
The implementation details vary from language to language, but the concept is the same.