2016-04-03 40 views
0

我有以下WAMPvhost重寫規則爲特定的項目文件夾(WAMP)

<VirtualHost *:80> 
ServerName testProject 
DocumentRoot c:/wamp64/www/testproject/public 
<Directory "c:/wamp64/www/testproject/public/"> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    Require local 
</Directory>  

當我訪問該鏈接testproject鏈接我的土地上testproject/home/。該testproject文件夾的結構如下:

enter image description here

裏面的.htaccessprofile-update文件夾我想應用RewriteRule。下面是裏面的代碼:

RewriteEngine On 
RewriteRule ^id/([0-9]+)/?$ /index.php?id=$1 [NC, L] 

我試圖從testproject/profile-update/?id=1URL改寫爲testproject/profile-update/id/1,但它似乎並沒有工作。

我檢查了類似的問題,並試圖,但沒有任何結果:

RewriteEngine On 
RewriteBase /public/ 
RewriteRule ^/public/profile-update/id/([0-9]+)/?$ /public/profile-update/index.php?id=$1 [NC, L] 

我在做什麼錯?

回答

0

您可以使用以下方法:

RewriteEngine On 
RewriteRule ^/?(?:profile-update/)?id/([0-9]+)/?$ /profile-update/index.php?id=$1 [NC,L] 
+0

剛剛加載的網址:HTTP':// testproject/profile文件更新/ ID/1'和得到的迴應:'請求的URL/profile文件更新/在這臺服務器上找不到id/1。' –

+0

任何線索爲什麼它不起作用? –

相關問題