![](/img/trans.png)
[英]Remove subfolder from url using only php code and not with help of .htaccess
[英]confusion with .htaccess code and URL and subfolder
我有這樣的.htaccess
重寫代碼
RewriteRule ^(.*)/(.*)$ edu.php?Main=$1&Category=$2 [QSA]
它適用於http://example.com/education/Main/Category
,其中“教育”是根目錄。 和Main和Category作為GET變量。
但是在我的PHP腳本中,有一個用於從目錄打印圖像的代碼。 代碼是這樣的
echo '<img src="http://example.com/education/subfolder/4.jpg" width="328" height="208" class="placeImage" />';
但這看起來像http://example.com/education/subfolder/4.jpg
,其中subfolder
是保存圖像的文件夾的名稱,而4.jpg
是圖像路徑。
但這由於上面的.htaccess
文件不起作用。 當我刪除上面的.htaccess
代碼時,將顯示圖像。 但是我的頁面URL也需要上面的.htaccess
代碼。 我很困惑。 有什么方法可以打印我的圖像而不更改該代碼。
像這樣嘗試您的htaccess,看看是否適合您。
RewriteEngine On
RewriteBase /education/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ /education/edu.php?Main=$1&Category=$2 [QSA,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.