我有我的htaccess代码的问题,问题是我不知道如何才能显示的代码index.php,我使用的代码是
RewriteEngine On
RewriteRule ^Page/([^/]*)$ /Page.php?v=$1 [L]
我的输出链接是www.expample.com/Page/1
上面的代码对除了索引页
之外的所有内容都有效。我现在需要做的是
index.php代替Page.php
i tried this way
RewriteRule ^/([^/]*)$ /index.php?v=$1 [L]
但也不能用
我现在需要的输出是从 转换链接 www.example.com/index.php?v=1
to www.example.com/1
对于第二个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]
Try This
RewriteRule ^ 1/?$ index . php ?v = 1 (QSA L)
我认为你不应该使用/index.php试试index.php
您可以使用以下规则重写到您的index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?v=$1 [L]
试试这样:
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s(.*)/index.php/?([^' '?]*) [NC]
RewriteRule ^ %1/%2 [R=301,L]
应该处理/index.php的任何位置