htaccess URL重定向到beta子文件夹,同时使用友好的URL重写

时间:2015-11-17 21:47:15

标签: regex .htaccess mod-rewrite redirect

您好,我有一个友好的URL网站的以下重定向

<IfModule mod_rewrite.c>

Options +FollowSymLinks -Multiviews

RewriteEngine on
RewriteBase /

RewriteRule ^$ /beta/ [L] // Got this from a fellow user in SO but didn't worked
RewriteRule ^home index.php
RewriteRule ^noticia/([\w-]+)/?$ noticia.php?title=$1 [L,QSA,NC]
RewriteRule ^busqueda/([\w-]+)/?$ busqueda.php?item=$1 [L,QSA,NC]
RewriteRule ^producto/([\w-]+)/?$ producto.php?item=$1 [L,QSA,NC]
RewriteRule ^noticias/page/([\w-]+)/?$ noticias.php?query=$1&page=$2 [L,QSA,NC]
RewriteRule ^noticias/tag/([\w-]+)/?$ noticias.php?query=$1&keyword=$2 [L,QSA,NC]
RewriteRule ^noticias/search/([\w-]+)/?$ noticias.php?query=$1&keyword=$2 [L,QSA,NC]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]


</IfModule>

以下是我网站的链接

SITE

我想要的是,当用户右转到该地址时,会被重定向到子文件夹中的Beta文件

REDIRECT

到目前为止我没有工作。

1 个答案:

答案 0 :(得分:1)

试试这个:

Options +FollowSymLinks -Multiviews    
RewriteEngine on
RewriteBase /

RewriteRule ^/?$ /beta/ [L,R]

RewriteRule ^home index.php [L]
RewriteRule ^noticia/([\w-]+)/?$ noticia.php?title=$1 [L,QSA,NC]
RewriteRule ^busqueda/([\w-]+)/?$ busqueda.php?item=$1 [L,QSA,NC]
RewriteRule ^producto/([\w-]+)/?$ producto.php?item=$1 [L,QSA,NC]
RewriteRule ^noticias/page/([\w-]+)/?$ noticias.php?query=$1&page=$2 [L,QSA,NC]
RewriteRule ^noticias/tag/([\w-]+)/?$ noticias.php?query=$1&keyword=$2 [L,QSA,NC]
RewriteRule ^noticias/search/([\w-]+)/?$ noticias.php?query=$1&keyword=$2 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]