mod_rewrite http://localhost/home/ or http://localhost/home to home.php

眉间皱痕 提交于 2019-12-25 04:55:45

问题


I've got a really simple question. I want to redirect all requests to http://localhost/home/ and http://localhost/home to home.php

My .htaccess file contains:

RewriteRule ^home/$ home.php [L]

which only works for http://localhost/home/

How can I make it work without the /in the url too? Is it possible to do it in one line, as opposed to two separate lines such as:

RewriteRule ^home/$ home.php
RewriteRule ^home$ home.php

Thanks :)


回答1:


RewriteRule ^home/?$ home.php [L]



回答2:


RewriteRule ^home/?$ home.php


来源:https://stackoverflow.com/questions/2117401/mod-rewrite-http-localhost-home-or-http-localhost-home-to-home-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!