mod_rewrite其他查询字符串 - 正确的语法

时间:2012-03-13 20:14:26

标签: .htaccess mod-rewrite friendly-url

我有一个相当标准的mod_rewrite,它与一个名为Modx的CMS打包在一起,而且FURL的工作正常。

它会重写

配置如下。

# Friendly URLs Part
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
# Force all pages to go to www.domain.co.uk for SEO
RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/dev/$1 [R=301,L]
# Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dev/index.php?q=$1 [L,QSA]

现在我想添加一个额外的条件来重写另一个查询字符串:

注意* company_id *和* company_id *应该是实际重写中的数字。

尝试了多次迭代,但仍然无法取得成功。

帮助赞赏!!

1 个答案:

答案 0 :(得分:1)

# Friendly URLs Part
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .

# Force all pages to go to www.domain.co.uk for SEO
RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/dev/$1 [R=301,L]
#are your sure the above rule shouldn't be :
#RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]

# Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ dev/index.php?q=$1 [L,QSA]

#company url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(company)/([^/]+)$ dev/index.php?q=$1&companyid=$2 [L,QSA]