子域重写的.htaccess [英] Subdomains rewrite .htaccess

查看:119
本文介绍了子域重写的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的这些规则,一切工作好。

I have these rules, everything work good.

我只需要添加此规则:

从it.domain.org/index.php?city=newyork到it.domain.org/product-usa-newyork~~V

from it.domain.org/index.php?city=newyork to it.domain.org/product-usa-newyork

唯一的变化是纽约。它也可以:lasvegas等。

The only thing that change is "newyork". It can be also: lasvegas etc..

推荐答案

试试你现有的规则之前插入这条规则的

Try inserting these 2 rules before your existing rules:

#Rewrite from http://it.domain.org/index.php?city=dc to http://it.domain.org/product-usa-dc
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.org$ [NC]
RewriteCond %{THE_REQUEST} \s/+index\.php\?city=([^\s&]+) [NC]
RewriteRule ^ /product-usa-%1? [R=302,L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.org$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^product-usa-([^/]+)/?$ /index.php?city=$1 [L,QSA,NC]

这篇关于子域重写的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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