2014-03-25 186 views
1

在使用.htaccess和冲突规则时遇到了一些麻烦。下面 代码:.htaccess冲突规则

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

Options +FollowSymLinks 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteCond %{SCRIPT_FILENAME} !-d 

DirectoryIndex index.php 

RewriteRule ^home/?$ index.php [L] 
RewriteRule ^([a-zA-Z0-9-]+)?$ static-page.php?slug=$1 [L] 

基于静态-page.php文件做工精细的网页,但是当我尝试去“/家”的页面加载了一会儿,然后给我什么。 我相信这是因为第二个规则是覆盖第一个规则。

任何人都知道如何解决这个问题?

感谢,

回答

1

试一下这个纠正代码:

DirectoryIndex index.php 
Options +FollowSymLinks -MultiViews 

RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{SCRIPT_FILENAME} -f [OR] 
RewriteCond %{SCRIPT_FILENAME} -d 
RewriteRule^- [L] 

RewriteRule ^home/?$ index.php [L] 

RewriteRule ^([a-zA-Z0-9-]+)?$ static-page.php?slug=$1 [L,QSA] 
+0

完美!感谢您的帮助:) –

+0

不客气,很高兴它解决了。 – anubhava