简体   繁体   中英

.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.

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.

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).

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.

No problem with my code, silly mistake ^_^.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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