Apache 重写cond/rewriterule

Apache 重写cond/rewriterule,apache,mod-rewrite,url-rewriting,rewrite,Apache,Mod Rewrite,Url Rewriting,Rewrite,我想我这里有一个好的 正在尝试在.htaccess文件中写入重写规则 如果传入的URL中有?p=,我需要重写为index.php。如果传入的只是域名www.myurl.com,我需要将其重写为home.php 这可能吗 谢谢。试试: RewriteEngine on #--If the incoming url has "?p="--# RewriteCond %{QUERY_STRING} p=.* [NC] #--Then redirect to /index.php--# Rewrite

我想我这里有一个好的

正在尝试在.htaccess文件中写入重写规则

如果传入的URL中有?p=,我需要重写为index.php。如果传入的只是域名www.myurl.com,我需要将其重写为home.php

这可能吗

谢谢。

试试:

RewriteEngine on

#--If the incoming url has "?p="--#
RewriteCond %{QUERY_STRING} p=.* [NC]
#--Then redirect to /index.php--#
RewriteRule ^ /index.php? [NC,L,R]
#--Else, redirect to home.php--#
RewriteRule ^$ /home.php [NC,L,R]