我有网址重写问题。
我只是尝试将 www.name.com/demo/profile 等智能网址重定向到现有网址: www.name.come / demo / index.php ?S =轮廓
我将.htaccess放在根目录中。
这是我的代码:
RewriteEngine On
RewriteRule ^demo/([a-z]+) demo/index.php?s=$1& [NC,L]
如果我写了像 www.name.com/demo/profile 这样的内容,它就无法运作。
服务器上的Mod Rewrite处于活动状态且工作正常(我尝试了其他示例)。
谢谢!
更新
数字可行。
我的规则:
RewriteEngine On
RewriteRule ^demo/([0-9]+) demo/index.php?s=$1& [NC,L]
智能网址: www.name.com/demo/1
现有网址:www.name.come / demo / index.php?s = 1
为什么它不能与角色合作?
答案 0 :(得分:2)
您需要为规则添加一些条件或使匹配更具限制性。尝试:
cREATE TABLE TEST12 (
X1 NUMBER(8),
X2 VARCHAR2(30),
x3 NUMBER(8)
);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'RRR08401000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'RRR06113000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'RRR05529000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'RRR05529000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'RRR49110RRRF',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42858,'34100000000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39916000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ00949000B',2);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ04888000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39915000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ38535000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ42350000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39746X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39743X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39923000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39745X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39744000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ03058X0AB',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39759000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39760000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39762000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39748000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39749000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39747000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ39742X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'XYZ47965000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'IUYI0902000E',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'IUYI0897000F',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42974,'IUYI0909000F',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39916000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ00949000B',2);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ04888000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39915000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ38535000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ42350000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39746X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39743X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39923000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39745X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39744000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ03058X0AB',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39759000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39760000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39762000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39748000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39749000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39747000A',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ39742X0AA',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'XYZ47965000B',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'IUYI0902000E',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'IUYI0897000F',1);
INSERT INTO TEST12 (X1, X2, X3) VALUES (42975,'IUYI0909000F',1);
或
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^demo/([a-z]+) demo/index.php?s=$1& [NC,L]
这样你的正则表达式就不会匹配" index.php"。