简体   繁体   English

.htaccess重写规则,导致空的$ _GET

[英].htaccess Rewrite rules causing empty $_GET

I am having a problem where on some of my clean url pages the $_GET values are returning as null. 我遇到一个问题,在某些干净的URL页面上,$ _ GET值返回为null。

My URL rewrites: 我的网址重写:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [L,R=301] !facebookexternalhit
RewriteCond %{HTTP_HOST} ^codesmite.com [NC] !facebookexternalhit
RewriteRule ^(.*)$ http://www.codesmite.com/$1 [L,R=301,NC,QSA]


# internally add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L,QSA]

RewriteRule ^([0-9]+)/?$ index2.php?section=index&page=$1 [NC,QSA]
RewriteRule ^freebies/?$ index2.php?section=freebies&page=1 [L,NC,QSA]
RewriteRule ^articles/?$ index2.php?section=articles&page=1 [L,NC,QSA]
RewriteRule ^deals/?$ index2.php?section=deals&page=1 [L,QSA,NC]
RewriteRule ^freebies/([0-9]+)/?$ index2.php?section=freebies&page=$1 [NC,L,QSA]
RewriteRule ^articles/([0-9]+)/?$ index2.php?section=articles&page=$1 [NC,L,QSA]
RewriteRule ^deals/([0-9]+)/?$ index2.php?section=deals&page=$1 [NC,L,QSA]
RewriteRule ^article/(.*)$ article.php?stitle=$1 [NC,L,QSA]
RewriteRule ^deal/(.*)$ deal.php?stitle=$1 [NC,L,QSA]
RewriteRule ^freebie/(.*)$ freebie.php?stitle=$1 [NC,L,QSA]
RewriteRule ^legal/?$ legal.php [NC,L,QSA]

The pages I am having problems with are: 我遇到问题的页面是:

www.example.com/articles/
www.example.com/freebies/
www.example.com/deals/

I am trying to set a value on these pages based on $_GET['section'] but $_GET array is null. 我试图基于$ _GET ['section']在这些页面上设置一个值,但是$ _GET数组为空。

There are also folders called "articles", "freebies" and "deals" located in the root directory (I do not know if this makes any difference to my problems). 根目录中还有文件夹“ articles”,“ freebies”和“ deals”(我不知道这对我的问题是否有影响)。

What am I doing wrong? 我究竟做错了什么?

Nevermind, as soon as I posted this question I noticed my mistake, forgot to change index2 to index from my test file to live file. 没关系,当我发布此问题时,我注意到我的错误,忘记了将index2更改为从测试文件到活动文件的索引。

No problem with my code, silly mistake ^_^. 我的代码没问题,愚蠢的错误^ _ ^。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM