.htaccess 我的URL中需要三个变量
我的URL中有3个变量需要在我的网站上使用:.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
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]