Talk:MediaWiki/archive/customizing/URLs

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search

question from anonymous user

Could you possibly give instructions if you use the "index.php?title=" method? because my server gets 404 errors with the /index.php/ method? i can't tell from your article which changes would be necessary.

how to use ?title=

Well, I haven't ever set that up myself, but I gather it's set in LocalSettings.php. With the normal setup (i.e. /index.php/articlename), you have these settings:

$wgScript           = "$wgScriptPath/index.php";
$wgArticlePath      = "$wgScript/$1";

...so I think what you would do is change the second setting:

$wgArticlePath      = "$wgScript/?title=$1";

I'm sure I've seen this explicitly spelled out somewhere in the MediaWiki documentation, but can't find it at the moment.

If that doesn't work, or doesn't answer your question, please let me know. --Woozle 21:32, 15 February 2006 (EST)

anonymous user replies

Yeah, I already know this. Mine is set up correctly as "$wgArticlePath = "$wgScript/?title=$1";" because I can't set it up as "$wgScript = "$wgScriptPath/index.php";" because it causes 404 errors. Something to do with my host. Anyways, what I was asking is what do I need to change in your instructions because mine will not replace /wiki/index.php/articlename and replace with /wiki/articlename but rather will replace /wiki/index.php?title=articlename and replace with /wiki/articlename. See what I am asking here? If the instructions are not any different, that's great. I'm just not sure. thanks!

Woozle responds

Oh, ok, I think I see what you mean.

At a guess, I think the same instructions would apply -- though really I should have to have a clearer understanding of why the "index.php/Title" method doesn't work for you in order to make an informed guess. (Do you have index.php set up as a default file in your .htaccess?)

Note that I've revised the "404 Method" instructions a bit -- I did some tests and solved some of the problems I was having earlier, although editing still does not work right.

In any case, if it doesn't work for you, let me know what happens... --Woozle 15:45, 16 February 2006 (EST)

Ash has same question

Okay, I also am required to have urls that use "index.php?title=$1". So, when I do this:

   <IfModule mod_rewrite.c>
       RewriteEngine on 
       RewriteCond %{REQUEST_FILENAME} !-f 
       RewriteCond %{REQUEST_FILENAME} !-d 
       RewriteRule ^(.*)$ index.php?title=$1 [L,QSA] 
   </IfModule>

with LocalSettings.php article path: $wgArticlePath = "/mydirectory/$1";

...I get a 500 internal server error. Of course, I don't know if the problem is with the code or the server. Any ideas?

Thank you! ---Ash

Woozle responds

Hmm.

  1. Do you have access to your server's error logs? Some of the better hosts let you get at these through the control panel, even if you don't have permission to get to the file itself. They can be maddeningly uninformative sometimes, and other times will show you exactly what the problem is with a sort of "you didn't ask" kind of smirk...
  2. Perhaps:
    • RewriteRule ^(.*)$ mydirectory/index.php?title=$1 [L,QSA]
    As I understand it, ^(.*)$ is a regex meaning "take everything in the original URL's path and stick it in $1", and the rest of the line means "and replace it with the following". So "http://yourdomain/yourwiki/SomePage" would translate to "http://yourdomain/yourwiki/index.php?title=SomePage", though you may need to tinker with it a bit (extra slashes and such). If you can't get it to work, I know someone who is good at reading regexes and may be able to spot where I've got it wrong ;-) (An example ugly-style URL that does work would be helpful, in this case.)

--Woozle 18:14, 18 August 2006 (EDT)


Alas, I do not have access to the error_log. Unfortunately, every combo of directory and no directory leads to the 500 error. It must be how the server is set up. Hopefully they can help me out...thanks for thinking about it. ---Ash
EDIT: Okay, I actually got it to work! The code I used was:

  SecFilterInheritance Off
  RewriteEngine on
  RewriteRule ^(.*)$ index.php?title=$1 [L,QSA]

However, I have a new problem...it isn't finding the stylesheet. I've tried putting in a hard link, and all kinds of additional calls to the htaccess, but they all go back to a 500 error. I guess I'll just keep banging away at it... Thanks again. ---Ash

A hint on that: make sure .css files are being sent with mime type text/css. If not, add this to .htaccess:

AddType text/css .css

You can use wget to find out what the headers are. If you're not using Linux, you can use Firefox's Page Info tool to get some of the same information. --Woozle 10:00, 19 August 2006 (EDT)