Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess多次重写?_Php_Html_.htaccess - Fatal编程技术网

Php .htaccess多次重写?

Php .htaccess多次重写?,php,html,.htaccess,Php,Html,.htaccess,我想重写到多个页面 我希望将对mysite.com/home的请求重写为mysite.com/home.php,并使用.htaccess文件将对mysite.com/u/erty5000的请求重写为mysite.com/profile.php?u=erty5000 这可能吗?如果是,怎么做 到目前为止,我就是这样将请求从mysite.com/home重写到mysite.com/home.php的 RewriteEngine On RewriteBase / RewriteCond %{REQUE

我想重写到多个页面

我希望将对mysite.com/home的请求重写为mysite.com/home.php,并使用.htaccess文件将对mysite.com/u/erty5000的请求重写为mysite.com/profile.php?u=erty5000

这可能吗?如果是,怎么做

到目前为止,我就是这样将请求从mysite.com/home重写到mysite.com/home.php的

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]

提前谢谢!:你已经有了第一条规则。但是,您必须排除
u/..
请求。添加一个,哪个可以执行此操作

RewriteCond %{REQUEST_URI} !^/u/
第二次重写的效果类似。从请求中提取所需的部分,并在替换中使用它

RewriteRule ^u/(.+)$ /profile.php?u=$1 [L,QSA]

你已经有了第一条规则。但是,您必须排除
u/..
请求。添加一个,哪个可以执行此操作

RewriteCond %{REQUEST_URI} !^/u/
第二次重写的效果类似。从请求中提取所需的部分,并在替换中使用它

RewriteRule ^u/(.+)$ /profile.php?u=$1 [L,QSA]