重写与查询字符串规则的子域名与rootdomain [英] Rewrite rules with query strings for subdomains with rootdomain

查看:170
本文介绍了重写与查询字符串规则的子域名与rootdomain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是专家在.htaccess。我要改写我的新闻和博客网址(带或不带WWW)为:

bdnews24.com/reporter.php?u=Name 于─> bdnews24.com/Name

m.bdnews24.com/reporter.php?u=Name 于─> m.bdnews24.com/Name

img.bdnews24.com/image.php?id=791011.jpg 于─> img.bdnews24.com/791011.jpg

bdnews24.com/details.php?id=100200300 于─> bdnews24.com/100200300

我目前的.htaccess文件小于,这是行不通的,因为我想它。 这捕获所有的请求的URI,如果不存在,它会去的index.php?U =任何事情

 选项+了FollowSymLinks
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
#AlegroCart重写启动
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)的index.php / $ 1 [L,QSA]
 

解决方案

这一套规则应该做你想要什么,根据您所提供的信息:

 的RewriteCond {%QUERY_STRING} ^ U =(。*)
的RewriteCond%{HTTP_HOST} ^(M ​​|。WWW)?bdnews.com $
重写规则^ reporter.php /%1?

的RewriteCond {%QUERY_STRING} ^ n =(。*)
的RewriteCond%{HTTP_HOST} ^ img.bdnews.com $
重写规则^ image.php /%1?

的RewriteCond {%QUERY_STRING} ^ n =(。*)
的RewriteCond%{HTTP_HOST} ^(M ​​|。WWW)?bdnews.com $
重写规则^ details.php /%1?
 

首先,它的查询字符串,然后将主机名(S),然后改写原来的查询字符串(%1)进入新的URL匹配。

I'm not expert in .htaccess. I want to rewrite my news and blog url (with or without www) as:

bdnews24.com/reporter.php?u=Name to-> bdnews24.com/Name

m.bdnews24.com/reporter.php?u=Name to-> m.bdnews24.com/Name

img.bdnews24.com/image.php?id=791011.jpg to-> img.bdnews24.com/791011.jpg

bdnews24.com/details.php?id=100200300 to-> bdnews24.com/100200300

My current .htaccess file is below, which is not working as I want it. This catches all request URI and if not exist it will go to index.php?u=ANYTHING

Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# AlegroCart REWRITES START
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php/$1 [L,QSA]

解决方案

This set of rules should do what you want, based on the information you've provided:

RewriteCond {%QUERY_STRING} ^u=(.*)
RewriteCond %{HTTP_HOST} ^(m.|www.)?bdnews.com$
RewriteRule ^reporter.php /%1?

RewriteCond {%QUERY_STRING} ^id=(.*)
RewriteCond %{HTTP_HOST} ^img.bdnews.com$
RewriteRule ^image.php /%1?

RewriteCond {%QUERY_STRING} ^id=(.*)
RewriteCond %{HTTP_HOST} ^(m.|www.)?bdnews.com$
RewriteRule ^details.php /%1?

First it matches the query string, then the host name(s), then rewrites the original query string (%1) into the new URL.

这篇关于重写与查询字符串规则的子域名与rootdomain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆