簡體   English   中英

url重寫htaccess問題

[英]url rewrite htaccess issue

我有網址:

http://127.0.0.1/myfolder/index.php

http://127.0.0.1/myfolder/index.php?error=1 ...

我該怎么做

http://127.0.0.1/rewritedpath/(index.php

http://127.0.0.1/rewritedpath/error/1(index.php?error = 1)

我已經烤了

RewriteEngine on
RewriteRule ^/?rewritedpath/ /myfolder/index.php
RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1

但這是行不通的。 怎么了 謝謝

更新


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1 [L]
RewriteRule ^/?rewritedpath/ /myfolder/index.php [L]

嘗試以下規則,

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

假設您的myfolder位於

在/ var / www / html等/ MyFolder文件

  1. 確保myfolder中的index.php
  2. 在/ var / www / html / rewritedpath /中創建.htaccess
  3. 將此代碼寫入新創建的.htaccess文件中

RewriteEngine On

RewriteRule ^(.*)$ ../myfolder/index.php?params=$1 [NC]

  1. 在位於myfolder的index.php文件中寫入此登錄名

$get = explode("/",$_GET['params']);

在$ get的$ get [0]中,您將得到您的鍵錯誤,而在$ get [1]中,您將得到您的值。

它將解析數組中的所有url參數。

暫無
暫無

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

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