簡體   English   中英

我如何從index.php htaccess中刪除參數

[英]how can i remove the parameter from index.php htaccess

我的htaccess代碼有問題,問題是我不知道如何顯示index.php的代碼,我正在使用的代碼是

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

對於第二個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]

嘗試這個

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的任何位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM