Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
如何重写example.com/catelogue.php?page=3&;cat1=水果和蔬菜;cat2=带.htaccess的苹果_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

如何重写example.com/catelogue.php?page=3&;cat1=水果和蔬菜;cat2=带.htaccess的苹果

如何重写example.com/catelogue.php?page=3&;cat1=水果和蔬菜;cat2=带.htaccess的苹果,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,有人能帮我修改一下.htaccess的url吗?我是新手,遇到了下面这个问题 我有这个网址 http://example.com/catelogue.php?page=3 http://example.com/catelogue.php?page=3&cat1=fruit&cat2=apple 我希望这样 http://example.com/catelogue http://example.com/catelogue/fruit/apple 下面是我的.htaccess

有人能帮我修改一下.htaccess的url吗?我是新手,遇到了下面这个问题

我有这个网址

http://example.com/catelogue.php?page=3

http://example.com/catelogue.php?page=3&cat1=fruit&cat2=apple
我希望这样

http://example.com/catelogue

http://example.com/catelogue/fruit/apple
下面是我的.htaccess文件,但这里的问题是我已经实现了这一点(example.com/catelogue/fruit/apple),但我无法将我的url重定向到(example.com/catelogue)


这应该行得通。这样试试你的规则。它对我有用

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^catelogue/([^/]+)/([^/]+)$ catelogue.php?page=3&cat1=$1&cat2=$2 [NC,L]
RewriteRule ^catelogue/?$ catelogue.php?page=3 [NC,L]
RewriteRule ^home/?$ index.php?page=1 [NC,L]
可能重复的
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^catelogue/([^/]+)/([^/]+)$ catelogue.php?page=3&cat1=$1&cat2=$2 [NC,L]
RewriteRule ^catelogue/?$ catelogue.php?page=3 [NC,L]
RewriteRule ^home/?$ index.php?page=1 [NC,L]