网址重写无法在wamp服务器

时间:2017-11-01 01:26:38

标签: php .htaccess url-rewriting wamp

您好我正在尝试练习网址重写。我在路径中写了.htaccess文件:C:\ wamp64 \ www \ RewriteUrl。在同一个地方我有文件pet_care_info_01_02_2008.php。我的重写规则是:

   RewriteEngine On    # Turn on the rewriting engine
   RewriteRule    ^pet-care/?$    pet_care_info_01_02_2008.php    [NC,L]    

所以我希望http://localhost/RewriteUrl/pet_care_info_01_02_2008.php更改为http://localhost/RewriteUrl/pet-care.php。但是目前它给了我整条路径而不是重写它。任何想法?

1 个答案:

答案 0 :(得分:0)

尝试:

RewriteEngine On    # Turn on the rewriting engine

# To externally redirect pet_care_info_ to pet_care.php
RewriteCond %{THE_REQUEST} /pet_care_info_ [NC]
RewriteRule ^ /RewriteUrl/pet_care\.php [R=301,L]

RewriteRule    ^pet_care\.php$    pet_care_info_01_02_2008.php    [NC,L]    

因为这就是你解释它的方式......
并尝试使用/RewriteUrl/pet_care.php