문제

I had installed wiki on my server. Lets say I have a domain name www.nikunj.com.

So installed wiki at this location www.nikunj.com/wiki.

Now I am trying to achieve that when any user types wiki.nikunj.com, he/she will see my installed wiki on www.nikunj.com/wiki.

도움이 되었습니까?

해결책

This issue should be solved in your webserver configuration.

I want to redirect

Apache HTTPD Server

If you use Apache, you can create a second VirtualHost for wiki.nikunj.com, with the purpose to redirect to www.nikunj.com/wiki.

With mod_rewrite:

<VirtualHost *:80>
    ServerName wiki.nikunj.com
    RewriteEngine on
    RewriteRule ^/(.*) http://www.nikunj.com/wiki/$1 [R,L]
</VirtualHost>

With mod_alias:

<VirtualHost *:80>
    ServerName wiki.nikunj.com
    RedirectMatch ^/(.*) http://www.nikunj.com/wiki/$1
</VirtualHost>

Nginx

Nginx syntax is more intuitive in this case:

server {
    server_name wiki.nikunj.com
    rewrite ^ http://www.nikunj.com$request_uri? permanent;
}

I want to keep the URL in wiki.

Apache

You need both mod_rewrite and mod_proxy. Then, it would be something like:

<VirtualHost *:80>
    ServerName wiki.nikunj.com
    RewriteEngine on
    RewriteRule ^/(.*) http://www.nikunj.com/wiki/$1 [R,L,P]
</VirtualHost>

Nginx

server {
    server_name wiki.nikunj.com
    proxy_pass http://www.nikunj.com/wiki;
}

What about short URLs?

You can use short URLs in this scenario.

You'll need two rules instead one, one for the articles (e.g. /view/$1), one for the other index.php links.

Tip: last in Nginx and [L] in Apache HTTPD means the current rule is the last executed. This will allow you to avoid the two rules are executed one after the other.

Documentation

다른 팁

The page you need to read, assuming "mediawiki" is what you're using, is this one, which describes the various choices you have available.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top