2016-04-03 46 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

任何线索为什么它不起作用? –