OK, this is my first attempt to use rewrite rules.
I've done the best I can to follow the instructions at http://www.mediawiki.org/wiki/Manual:Short_URL/Apache .
I've created an .htaccess file and put it at root at http://www.vanslyck.us as follows:
## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache # Follow symbolic links(dunno if this is needed or not) Options +FollowSymLinks # Enable the rewrite engine RewriteEngine On # Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
then I added the following lines to the end of LocalSettings.php:
# Enable Short URLs # http://www.mediawiki.org/wiki/Manual:Short_URL $wgUsePathInfo = true; # added this after getting the redirect loop error. $wgScriptPath = "/wiki"; $wgArticlePath = "/wiki/$1";
Can anyone see something obviouis that I know how to recognize?
Go to
http://shorturls.redwerks.org/ as recommended on
http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
And use it to generate everything you need to do.
Tom
On Jan 12, 2013, at 8:03 PM, Steve VanSlyck s.vanslyck@spamcop.net wrote:
OK, this is my first attempt to use rewrite rules.
I've done the best I can to follow the instructions at http://www.mediawiki.org/wiki/Manual:Short_URL/Apache .
I've created an .htaccess file and put it at root at http://www.vanslyck.us as follows:
## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache # Follow symbolic links(dunno if this is needed or not) Options +FollowSymLinks # Enable the rewrite engine RewriteEngine On # Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
then I added the following lines to the end of LocalSettings.php:
# Enable Short URLs # http://www.mediawiki.org/wiki/Manual:Short_URL $wgUsePathInfo = true; # added this after getting the redirect loop error. $wgScriptPath = "/wiki"; $wgArticlePath = "/wiki/$1";
Can anyone see something obviouis that I know how to recognize? _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Yep, tried that. Wouldn't work. It reported, "We found a rel=EditRSD for your wiki, however the resulting document did not declare the location of a MediaWiki installation's API point in it. Are you sure you gave the url to your MediaWiki installation? If you gave the correct url your install may be customized or broken in a way that prevents us from detecting the location of your wiki's api and coming up with shorturl configuration for you."
On 1/12/2013 20.15, Tom wrote:
Go to
http://shorturls.redwerks.org/ as recommended on
http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
And use it to generate everything you need to do.
Tom
On Jan 12, 2013, at 8:03 PM, Steve VanSlyck s.vanslyck@spamcop.net wrote:
OK, this is my first attempt to use rewrite rules.
I've done the best I can to follow the instructions at http://www.mediawiki.org/wiki/Manual:Short_URL/Apache .
I've created an .htaccess file and put it at root at http://www.vanslyck.us as follows:
## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache # Follow symbolic links(dunno if this is needed or not) Options +FollowSymLinks # Enable the rewrite engine RewriteEngine On # Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
then I added the following lines to the end of LocalSettings.php:
# Enable Short URLs # http://www.mediawiki.org/wiki/Manual:Short_URL $wgUsePathInfo = true; # added this after getting the redirect loop error. $wgScriptPath = "/wiki"; $wgArticlePath = "/wiki/$1";
Can anyone see something obviouis that I know how to recognize? _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
------------------------------------------------------------------------ On 1/12/2013 8:18 PM, Steve VanSlyck wrote:
Yep, tried that. Wouldn't work. It reported, "We found a rel=EditRSD for your wiki, however the resulting document did not declare the location of a MediaWiki installation's API point in it. Are you sure you gave the url to your MediaWiki installation? If you gave the correct url your install may be customized or broken in a way that prevents us from detecting the location of your wiki's api and coming up with shorturl configuration for you."
That's because you have your wiki locked down.
<error code="readapidenied" info="You need read permission to use this module" xml:space="preserve">
Glad you figured it out... Tom
On 01/12/2013 08:03 PM, Steve VanSlyck wrote:
# Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
%{DOCUMENT_ROOT} is wrong there.
Try replacing those lines with this:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/?wiki/(.*)$ /wiki/index.php?title=$1 [L,QSA] RewriteRule ^/*$ /wiki/Main_Page [L,QSA]
HTH,
Mark.
OK,
That's working great - thanks Mark! Can this be adjusted so that calls to http:mysite.com redirect to http://_www_.mysite.com?
On 1/12/2013 20.17, Mark A. Hershberger wrote:
On 01/12/2013 08:03 PM, Steve VanSlyck wrote:
# Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
%{DOCUMENT_ROOT} is wrong there.
Try replacing those lines with this:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/?wiki/(.*)$ /wiki/index.php?title=$1 [L,QSA] RewriteRule ^/*$ /wiki/Main_Page [L,QSA]
HTH,
Mark.
On 01/12/2013 08:44 PM, Steve VanSlyck wrote:
That's working great - thanks Mark! Can this be adjusted so that calls to http:mysite.com redirect to http://_www_.mysite.com?
Sure. You just need to add these three lines right before those lines:
RewriteCond %{HTTP_HOST} !^www.example.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]
(From https://httpd.apache.org/docs/2.2/rewrite/remapping.html#canonicalhost)
Mark,
Because I have C-O-D where documentation is concerend (C-O-D is OCD with the letters /in the correct order/), I boldly went where maybe I shouldn't have and made an update to the manual.
You might wish to check out http://www.mediawiki.org/w/index.php?title=Manual%3AShort_URL%2FApache&d... and evaluate the accuracy of that diff.
Thanks again.
On Sat, 12 Jan 2013 17:17:41 -0800, Mark A. Hershberger mah@everybody.org wrote:
On 01/12/2013 08:03 PM, Steve VanSlyck wrote:
# Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
%{DOCUMENT_ROOT} is wrong there.
Try replacing those lines with this:
RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/?wiki/(.*)$ /wiki/index.php?title=$1 [L,QSA] RewriteRule ^/*$ /wiki/Main_Page [L,QSA]
HTH,
Mark.
Ugh... I wish I had seen this before. This advice is completely off. %{DOCUMENT_ROOT} is not wrong. Though /w/ is. And that ?title=$1 shouldn't be there.
The proper rules are:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d RewriteRule ^/?wiki/(.*)$ %{DOCUMENT_ROOT}/wiki/index.php [L] RewriteRule ^/*$ %{DOCUMENT_ROOT}/wiki/index.php [L]
On 01/15/2013 11:33 PM, Daniel Friesen wrote:
%{DOCUMENT_ROOT} is not wrong. Though /w/ is. And that ?title=$1 shouldn't be there.
The rules work for me and others. Your suggested rules work, I'm sure, but they make me cringe ("Ugh!") -- especially the %{DOCUMENT_ROOT}%{REQUEST_URI} bit instead of %{REQUEST_FILENAME}.
Can't we all be friends?
On Tue, 15 Jan 2013 22:53:00 -0800, Mark A. Hershberger mah@everybody.org wrote:
On 01/15/2013 11:33 PM, Daniel Friesen wrote:
%{DOCUMENT_ROOT} is not wrong. Though /w/ is. And that ?title=$1 shouldn't be there.
The rules work for me and others. Your suggested rules work, I'm sure, but they make me cringe ("Ugh!") -- especially the %{DOCUMENT_ROOT}%{REQUEST_URI} bit instead of %{REQUEST_FILENAME}.
The current rules I'm suggesting are developed to work the best way and work in nearly all configuration situations.
%{DOCUMENT_ROOT}%{REQUEST_URI} comes out of an issue with %{REQUEST_FILENAME}. One day I discovered a user who had some unexpected when they tried to configure their root short urls. It turns out that when rewrite rules are placed directly into a <VirtualHost> block %{REQUEST_FILENAME} is empty. Which leads to bugs in the rewrite rules. So it was replaced with %{DOCUMENT_ROOT}%{REQUEST_URI} which ends up with pretty much the same value but is never blank.
Can't we all be friends?
On 01/17/2013 07:54 PM, Daniel Friesen wrote:
It turns out that when rewrite rules are placed directly into a <VirtualHost> block %{REQUEST_FILENAME} is empty. Which leads to bugs in the rewrite rules. So it was replaced with %{DOCUMENT_ROOT}%{REQUEST_URI} which ends up with pretty much the same value but is never blank.
Just this past week, I upgraded a wiki and moved the rewrite rules to the <VirtualHost> block. They worked. Here they are:
<VirtualHost *:80> ... <Location /RKB> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/?(.*)$ /RKB/index.php [L,QSA] </Location> ... </VirtualHost>
Maybe there is something else that caused a problem for you? Maybe it was an Apache version?
Server version: Apache/2.2.22 (Ubuntu) Server built: Nov 8 2012 21:37:45
Is there some problem I may be running into here?
Mark.
On Sat, 12 Jan 2013 17:17:41 -0800, Mark A. Hershberger mah@everybody.org wrote:
RewriteRule ^/?wiki/(.*)$ /wiki/index.php?title=$1 [L,QSA]
I think this might cause issues with page names containing characters which are differently encoded in URL paths and URL queries, like + (which means a plus in a path, and a space in a query) – please correct me if I'm wrong.
Your $wgScriptPath should be where your script files are which is not the same as your article path. Typically $wgScriptPath = "/w". Where have you installed your files relative to the root of your web server?
On 12 January 2013 20:03, Steve VanSlyck s.vanslyck@spamcop.net wrote:
OK, this is my first attempt to use rewrite rules.
I've done the best I can to follow the instructions at http://www.mediawiki.org/wiki/**Manual:Short_URL/Apachehttp://www.mediawiki.org/wiki/Manual:Short_URL/Apache.
I've created an .htaccess file and put it at root at http://www.vanslyck.us as follows:
## http://www.mediawiki.org/wiki/**Manual:Short_URL/Apachehttp://www.mediawiki.org/wiki/Manual:Short_URL/Apache # Follow symbolic links(dunno if this is needed or not) Options +FollowSymLinks # Enable the rewrite engine RewriteEngine On # Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.**php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
then I added the following lines to the end of LocalSettings.php:
# Enable Short URLs # http://www.mediawiki.org/wiki/**Manual:Short_URLhttp://www.mediawiki.org/wiki/Manual:Short_URL $wgUsePathInfo = true; # added this after getting the redirect loop error. $wgScriptPath = "/wiki"; $wgArticlePath = "/wiki/$1";
Can anyone see something obviouis that I know how to recognize? ______________________________**_________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.**org MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-lhttps://lists.wikimedia.org/mailman/listinfo/mediawiki-l
LocalSettings.php says: $wgScriptPath = "/wiki";
On 1/12/2013 20.22, Dave Humphrey wrote:
Your $wgScriptPath should be where your script files are which is not the same as your article path. Typically $wgScriptPath = "/w". Where have you installed your files relative to the root of your web server?
On 12 January 2013 20:03, Steve VanSlyck s.vanslyck@spamcop.net wrote:
OK, this is my first attempt to use rewrite rules.
I've done the best I can to follow the instructions at http://www.mediawiki.org/wiki/**Manual:Short_URL/Apachehttp://www.mediawiki.org/wiki/Manual:Short_URL/Apache.
I've created an .htaccess file and put it at root at http://www.vanslyck.us as follows:
## http://www.mediawiki.org/wiki/**Manual:Short_URL/Apachehttp://www.mediawiki.org/wiki/Manual:Short_URL/Apache # Follow symbolic links(dunno if this is needed or not) Options +FollowSymLinks # Enable the rewrite engine RewriteEngine On # Short url for wiki pages(dunno if [PT,L] is required instead) RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/wiki/index.**php [L] # Redirect / to Main Page(dunno if [PT,L] is required instead) RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
then I added the following lines to the end of LocalSettings.php:
# Enable Short URLs # http://www.mediawiki.org/wiki/**Manual:Short_URLhttp://www.mediawiki.org/wiki/Manual:Short_URL $wgUsePathInfo = true; # added this after getting the redirect loop error. $wgScriptPath = "/wiki"; $wgArticlePath = "/wiki/$1";
Can anyone see something obviouis that I know how to recognize? ______________________________**_________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.**org MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/**mailman/listinfo/mediawiki-lhttps://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org