简体   繁体   中英

Redirect everything BUT index.php with htaccess

I have a dilemma with a site I own and how to configure the .htaccess file.

I just to had a forum in mysite.com, since I wanted to add a blog I put a 301 redirect and move everything to a dir mysite.com/forum/, all good there.

But now I want to had a different index page so people can choose between go to the blog (blogs actually) or go to the forum.

I trying to avoid losing several pages already indexed by web searchers.

Right now the htaccess file in the root of my site looks like:

Options +FollowSymLinks
RewriteEngine on
<Files 403.shtml>
order allow,deny
allow from all
</Files>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirigir el dominio sin www a www
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,QSA,L]

RewriteRule (.*) http://www.mysite.com/forum/$1 [R=301,L]
</IfModule>

Is there a way to put something like

If request URL = root then index.php
Else http://www.mysite.com/forum/$1

Thanks for your help

Cheers!

You probably want something like

# if request = root
RewriteRule ^/?$ /index.php [L]
# else
RewriteRule !^/?(index\.php)?$ http://www.mysite.com/forum%{REQUEST_URI} [L,R=301]

To replace the last rule that you have

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM