htaccess URL redirect to beta subfolder, while using friendly URL rewrite

荒凉一梦 提交于 2020-01-05 15:17:26

问题


Hi I have the following redirection for a friendly URL site

<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>

Here is the link to my site

SITE

I want that, when an user goes right to that address, gets redirected to a Beta file in a subfolder

REDIRECT

What I have so far is not working.


回答1:


Try this:

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]


来源:https://stackoverflow.com/questions/33767642/htaccess-url-redirect-to-beta-subfolder-while-using-friendly-url-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!