2017-06-22 217 views
1

您好我现在有这个作为我的.htaccess文件:查询字符串路径

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteRule ^/(assets|modules|plugins)/ - [NC,L,QSA]                                         
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s                                         
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d [OR]                                        
RewriteRule (.*) - [NC,L,QSA,S=3]                                             
RewriteRule ^/(.*)/(.*)$ /$1?type=$2 [NC,QSA]                                          
RewriteRule ^/(.*)$ /index.php?page=$1 [NC,L,QSA] 
</IfModule> 

这是从Apache虚拟主机配置移动为.htaccess,但我得到404的。

例如:我想这个页面http://stripsync.com/index.php?page=venue看起来像这样http://stripsync.com/venue

我在做什么错?所有帮助非常感谢!

回答

0

将其更改为此,因为您将其移至.htaccess(其不包括它们在匹配中),因此已在此上下文中删除,因此将其更改为除去开放正斜杠。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(assets|modules|plugins)/ - [NC,L]                                         
    RewriteCond %{ENV:REDIRECT_REWRITTEN} =1 [OR] 
    RewriteCond %{REQUEST_FILENAME} -s [OR] 
    RewriteCond %{REQUEST_FILENAME} -d 
    RewriteRule^- [L] 
    RewriteRule ^(.*)/(.*)$ /$1?type=$2 [QSA,L,E=REWRITTEN:1] 
    RewriteRule ^(.*)$ /index.php?page=$1 [QSA,L,E=REWRITTEN:1] 
</IfModule> 

我删除了未使用的标志并捕获。

+0

当我使用你的例子时,我得到一个500错误。 它有助于提供我的全局变量和index.php文件的例子吗? – ewoah

+0

对不起。我更新了规则,你可以再试一次吗?如果它仍然是500,请让我知道错误日志说什么。 – SuperDuperApps

+0

它的工作表示感谢! – ewoah