Jump to content

Recommended Posts

Posted

ok, so for my sitel i have decided to set up the WikiMedia wiki and i have installed that fine. i installed it in a folder named 'wiki' and am using it as the subdomain http://wiki.sorune.com right now in the .htaccess file, i have:

>RewriteBase / RewriteRule test.html$ index.php

just so i could try and see if the module would work. right now the wiki is loaded as http://wiki.sorune.com/index.php/Main_Page which isnt all that bad, but i would like it to load as http://wiki.sorune.com/Main_Page i have tried many different configurations in .htaccess and talked with people i know on irc, but i always get a 500 internal service error. most of the code that i tried first was from this site. any help would be greatly appreciated.

 

-noiz

Posted

You're trying to rewrite a dynamic URL to look like a static URL, and you want to hide the actual dynamic URL from visitors, right?

 

Is your .htacess file in the /wiki/ folder? (This idea assumes it is)

 

If so, I think you should be able to use

 

RewriteRule ^/(.*)$ index.php?variable=$1

 

Where variable is the PHP variable you use on your index.php page. It won't be visible to site visitors, who will only see wiki.******/Main_page -- at least, that's all they'll see if you always use wiki.******/Main_page as the link and don't use the wiki.******/index.php?variable=Main_page as a link anywhere.

 

I think. I use a similar rule, but it isn't in a subdomain. I don't know how that would affect things.

 

The problem with the RewriteRule I just offered is that it's going to take every URL starting from the /wiki/folder and try to rewrite it to index.php?variable=/whatever/folders/you/have/in/the/link

 

Not a great idea, if you plan on having any subfolders in /wiki/

 

In that case, you probably need an identifier of some sort, so you can specifiy which URLs get written to this index file:

 

RewriteRule ^/a/(.*)$ index.php?variable=$1

 

/a/ can be any identifier you want it to be, as long as it's not the name of a real sub folder.

 

I'm not guarunteeing this will work, but the problem looks similar to something I tackled on my blog, and this is how I got around it. But I don't have a subdomain in there. And my .htaccess file is located in the /blog/ folder, which is where all the redirecting starts. And I'm not an .htaccess expert, but it looks to me like the problem is you aren't defining which part of the fake URL needs to be rewritten onto the new URL -- that's the $1 bit. And that's the end of my disclaimers.

 

Someone with a better grasp of .htaccess may be able to offer a more elegant solution.

Posted

Do your error logs say what URL it was trying to access when it got the 400 error? That would help sort out how the RewriteRule is actually rewriting the URL and what would need to be changed.

Posted
Do your error logs say what URL it was trying to access when it got the 400 error? That would help sort out how the RewriteRule is actually rewriting the URL and what would need to be changed.

File does not exist: /home/sorunec/public_html/wiki/Main_Page

thats what my error logs say.

 

-noiz

Posted

Ok, try this:

 

RewriteBase /

RewriteRule ^(.*)$ /index.php?variable=$1

 

This is almost the same as before, but take the slash out of the RewriteRule.

Again, I'm assuming you're putting this .htaccess file in the /wiki/ folder and that you're changing the index.php?variable to whatever is relevant.

 

If that doesn't work, try

 

RewriteBase /

RewriteRule ^(.*)$ http://wiki.******/index.php?variable=$1

 

And if that doesn't work, then I'm guessing something in the fact that you have a subdomain is messing up the write rules. But see what happens.

 

[edited to point out that the subdomain isn't at fault as much as my limited knowledge is]

Posted

if didnt work for me, but ive decided to try aliasing the url instead. i tried putting this:

>Alias /stylesheets /home/sorunec/public_html/wiki/stylesheets
Alias /style /home/sorunec/public_html/wiki/style
Alias /images /home/sorunec/public_html/wiki/images
Alias /skins /home/sorunec/public_html/wiki/skins
Alias /redirect.php /home/sorunec/public_html/wiki/redirect.php
Alias /textvc.php /home/sorunec/public_html/wiki/textvc.php
Alias /index.php /home/sorunec/public_html/wiki/index.php
Alias / /home/sorunec/public_html/wiki/index.php

into .htaccess in the wiki folder, but i got a 500 internal server error and my error log says "/home/sorunec/public_html/wiki/.htaccess: Alias not allowed here" is there any other place that i would put that code where aliases are allowed, or does TCH just not allow aliases?

 

-noiz

Posted

The Alias directive can only be used in server-level configuration files (httpd.conf, srm.conf, and access.conf), which users do not have access to. It is not allowed in an .htaccess file - this is an Apache restriction, not TCH.

Posted

If you want to PM me and let me know what exactly was in the .htacess file when you got the first redirect to work (http://wiki.yoursite.com/index.php/Main_Page), I might be able to help you work out the RewriteRule thing. It's just hard to know what's going wrong since I don't know exactly what you're using.

 

You could also try http://forum.modrewrite.com/ ; I was able to fix several problems reading through their forum. They might be able to help you out.

Posted
If you want to PM me and let me know what exactly was in the .htacess file when you got the first redirect to work (http://wiki.yoursite.com/index.php/Main_Page), I might be able to help you work out the RewriteRule thing. It's just hard to know what's going wrong since I don't know exactly what you're using.

 

You could also try http://forum.modrewrite.com/ ; I was able to fix several problems reading through their forum. They might be able to help you out.

i was able to get the url to change to what i wanted but now when i have the url changed, mediawiki cannot load the stylesheets, which is a pretty big problem...

 

-noiz

Posted

TCH supports Rewrite rules in htaccess files? That is awesome.

I use that on several non-TCH sites for blocking people who try

to steal images, stop common forum attack exploits, and such.

Makes me feel better that I could bring those sites to TCH. :)

Posted

Do you have mod_rewrite rules like these in your .htaccess file prior to the rule that you've been working on, so mod_rewrite does not process the URLs for your stylesheets?

># Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !^/wiki/(stylesheets|images|skins)/
RewriteCond %{REQUEST_URI} !^/wiki/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt

(The above was taken from the MediaWiki Rewrite Rules page linked to in the first post.)

Posted
Do you have mod_rewrite rules like these in your .htaccess file prior to the rule that you've been working on, so mod_rewrite does not process the URLs for your stylesheets?

># Don't rewrite requests for files in MediaWiki subdirectories,
# MediaWiki PHP files, HTTP error documents, favicon.ico, or robots.txt
RewriteCond %{REQUEST_URI} !^/wiki/(stylesheets|images|skins)/
RewriteCond %{REQUEST_URI} !^/wiki/(redirect|texvc|index).php
RewriteCond %{REQUEST_URI} !^/error/(40(1|3|4)|500).html
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt

(The above was taken from the MediaWiki Rewrite Rules page linked to in the first post.)

yes, i already included those exceptions from that site, but now im getting people to help me on the #mediawiki irc channel, so hopefully since they know a lot about the mediawiki code they will be able to solve this problem.

 

-noiz

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...