2015-09-04 67 views
1

我有问题,我的htaccess代码的问题是我不知道我怎么可以显示的index.php代码, 我正在使用的代码是如何从的index.php htaccess的删除参数

RewriteEngine On 
    RewriteRule ^Page/([^/]*)$ /Page.php?v=$1 [L] 

和我的输出链接是www.expample.com/Page/1

上述SIS的每一件事情,除了工作的索引页

什么,我现在需要做的是

代码

的index.php,而不是page.php文件

我想这样

 RewriteRule ^/([^/]*)$ /index.php?v=$1 [L] 

而且它不工作

,我现在需要的是该链接从

转换输出www.example.com/index.php?v=1www.example.com/1

回答

2

对于第二个index.php规则,您需要使用RewriteCond避免重写文件或目录:

Options -MultiViews 
RewriteEngine On 

RewriteRule ^Page/([^/]*)$ Page.php?v=$1 [L,QSA,NC] 

# if request is not for a file 
RewriteCond %{REQUEST_FILENAME} !-d 
# if request is not for a directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L,QSA] 
+1

非常感谢你是的工作 – badr

0

尝试这个

重写规则^ 1/$的index.php V = 1 [QSA,L]

我认为你不应该使用?的index.php尝试的index.php

0

您可以使用以下规则来重写你的index.php

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L] 
0

试试这样的:

RewriteBase/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index.php/?([^\ \?]*) [NC] 
RewriteRule^%1/%2 [R=301,L] 

这应该处理/index.php的任何位置。