Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
.htaccess 我的URL中需要三个变量_.htaccess_Url_Url Rewriting - Fatal编程技术网

.htaccess 我的URL中需要三个变量

.htaccess 我的URL中需要三个变量,.htaccess,url,url-rewriting,.htaccess,Url,Url Rewriting,我的URL中有3个变量需要在我的网站上使用:page、x和action 像这样: /?page=category&x=geografi&action=succes 我写道: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} /([a-zA-Z0-9]+) RewriteRule ^([a-zA-Z0-9]+)$ index.p

我的URL中有3个变量需要在我的网站上使用:
page
x
action

像这样:

/?page=category&x=geografi&action=succes
我写道:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /

   RewriteCond %{REQUEST_URI} /([a-zA-Z0-9]+)
   RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1

   RewriteCond %{REQUEST_URI} /([a-zA-Z0-9]+)/
   RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_URI}/([a-zA-Z0-9]+)
重写规则^([a-zA-Z0-9]+)$index.php?页面=$1
重写cond%{REQUEST_URI}/([a-zA-Z0-9]+)/
重写规则^([a-zA-Z0-9]+)/$index.php?页面=$1

有了这些代码,我就正确地获得了页面变量,但我需要另外两个…

假设您是从
/category/geografi/success

您可以使用以下内容:

RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?page=$1&x=$2&action=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ index.php?page=$1&x=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?page=$1 [L]

这些是从目录结构中提取的还是作为查询提交的?Thx它可以工作,但不能使用这些字符(-)。我需要它们:SRewriteRule^u/([a-zA-Z0-9-/]+)/([a-zA-Z0-9-/]+)/([a-zA-Z0-9-/]+)/?$user profile.php?用户名=$1&navigation=$2&frame=$3[L]重写规则^u/([a-zA-Z0-Z0-9-/])/)/?$user profile.php?用户名=$1和导航=$2[L]重写规则^u/([a-zA-Z0-9-/]+)/?$user profile.php?用户名=$1[L]