开发者

Apache Redirect Rule Needed.Thanks!

开发者 https://www.devze.com 2023-01-24 03:12 出处:网络
everyone I have one problem here. My site is powered by Mediawiki, which means, the visitors are supposed to visit links like this:

everyone I have one problem here. My site is powered by Mediawiki, which means, the visitors are supposed to visit links like this:

hxxp://www.example.com/wiki/SOMETHING

I want to redirect the user to the Main Page if he is tr开发者_如何学JAVAying to access something else:

hxxp://www.example.com/NOTwiki/SOMETHING -> hxxp://www.example.com/wiki/Main_Page

and

hxxp://www.example.com/NOTwiki -> hxxp://www.example.com/wiki/Main_Page

And "/wiki" is case sensitive, which means:

hxxp://www.example.com/WiKi/SOMETHING    -> hxxp://www.example.com/wiki/Main_Page

I am using a virtual host like this:

<VirtualHost 12.34.56.78:80>
ServerName example.com
ServerAdmin admin@example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example/public_html/mediawiki/
ErrorLog logs/AP/error_log
</VirtualHost> 

I am new on Apache and still learning.

Be specific,Please.

Thanks a lot!


This config should be:

<IfModule mod_rewrite.c>
   RewriteBase /
   RewriteEngine on

   RewriteCond %{ENV:REDIRECT_STATUS} 200
   RewriteCond %{REQUEST_URI} ^index.php
   RewriteRule .* - [L]

   RewriteRule !^wiki(/.*)?$ wiki/Main_Page [R=301,L]

</IfModule>

The RewriteCond/RewriteRule says "If the start of the path is not /wiki, rewrite all URLS to /wiki/Main_Page using a 301 redirect (R=301), and do not process any more rules (L)"

0

精彩评论

暂无评论...
验证码 换一张
取 消