簡體   English   中英

如何排除GET變量並重寫為重定向URL

[英]How to exclude a GET variable and rewrite as a redirect url

我想將test.com/folder/create重定向到test.com/folder/create(.php)但將/folder/之后的任何內容都視為$_GET[]變量,並包含以下$_GET[]

 RewriteCond %{REQUEST_URI} !^/folder/index\.php$ [NC] 
 RewriteRule ^folder/([^/]*)$ /folder/index.php?type=$1

我試過了

 RewriteCond %{REQUEST_URI} !^/folder/create\.php$ [NC]
 RewriteRule ^folder/create$ /folder/create.php

但是沒有運氣( 錯誤500 ),有人能指出我該如何做的正確方向嗎?

編輯:仍然試圖在網絡上尋找答案,沒有運氣

編輯:小編輯,當前代碼

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^item\.php$ 

RewriteRule ^([^/]+)/?$ index.php?type=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?type=$1&page=$2 [L,QSA]

RewriteRule ^item/([^/]+)/?$ item.php?id=$1 [L,QSA]
RewriteRule ^item/([^/]+)/([^/]+)/?$ item.php?id=$1&page=$2 [L,QSA]

重寫基礎是/ folder / / folder / item作品,並重定向到item.php / folder / item / 2給出了500錯誤,有什么建議嗎?

僅嘗試:

Options -MultiViews
RewriteRule ^folder/create$ folder/create.php

您可以在folder/.htaccess使用這些規則(不在網站根目錄.htaccess中使用):

DirectoryIndex index.php
RewriteEngine On
RewriteBase /folder/

# append .php extension to every request that has a corresponding .php file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

# rewrite all non-existing files and folders to index,php?type=...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ index.php?type=$0 [L,QSA]

暫無
暫無

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

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