2014-12-02 140 views
1

我想重写.htaccesss重写规则将无法正常工作

HTTTP://www.site.ru/company.html名= bestcompany

HTTTP://www.site .ru/company/bestcompany.html

请建议我错在哪里。我做什么:

RewriteRule ^company/([^/]*)\.html$ /company.html?name=$1 [L] 

CMS镆铘,在根文件夹.htacces,全面的.htaccess代码:

RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} . 
RewriteCond %{HTTP_HOST} !^www\.site\.ru [NC] 
RewriteRule (.*) http://www.site.ru/$1 [R=301,L] 

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

RewriteRule ^company/([^/]*)\.html$ /company?name=$1 [L] 

回答

0

重新安排你的规则是这样的:

RewriteEngine On 
RewriteBase/

RewriteCond %{HTTP_HOST} . 
RewriteCond %{HTTP_HOST} !^www\.site\.ru [NC] 
RewriteRule (.*) http://www.site.ru/$1 [R=301,L,NE] 

RewriteCond %{THE_REQUEST} \s/+(company)(?:\.html)?\?name=([^\s&]+) [NC] 
RewriteRule^/%1/%2.html? [R=302,L,NE] 

RewriteRule ^company/([^./]+)\.html$ /company?name=$1 [L,NC,QSA] 

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

谢谢,但它不帮助。 – 2014-12-02 06:24:31

+1

该评论也无济于事。提供详细信息什么是您在浏览器中输入的完整URL以及您得到了什么错误? – anubhava 2014-12-02 06:28:29

+0

完整的网址:htttp://www.site.ru/company.html?name = firstcompany它没有错误,我知道.htacees友好的URL部分工作,但url不会更改为htttp://www.site.ru /company/firstcompany.html – 2014-12-02 06:30:27