Reputation: 163
I am beginner in url rewriting and i have studied about it from various sources.Everything seems to be working till now but this is just not working.
I have this line of code in my htaccess file.
RewriteRule ^notice/all/page/([0-9]+)/?$ files/all_notice.php?show=all&page=$1 [NC,L]
This is the url i am visiting
http://localhost/notice/all/page/1
and when reading variables in php like this-
<?php
$type=$_GET['show'];
$page=$_GET['page'];
echo $type.'--'.$page;
?>
This is what i get
all--notice
I am getting the show variable as it is but instead of page number i am getting notice. What is going wrong?
Upvotes: 0
Views: 36
Reputation: 26066
Your RewriteRule
is this:
RewriteRule ^notice/all/page/([0-9]+)/?$ files/all_notice.php?show=all&page=$1 [NC,L]
Try this:
RewriteRule ^notice/all/page/([0-9]+)/?$ /files/all_notice.php?show=all&page=$1 [L]
The only difference is the addition of a /
in front o files/…
and removing the NC
so it is only [L]
.
EDIT: And perhaps you should see what happens if you change that $1
to $2
, $3
or even $4
to see if any of those values get passed through.
Upvotes: 2
Reputation: 3754
Try this:
RewriteRule ^notice/all/page/([0-9]+)?$/ files/all_notice.php?show=all&page=$1 [NC,L] //for urls like localhost/notice/all/page/1/
RewriteRule ^notice/all/page/([0-9]+)?$ files/all_notice.php?show=all&page=$1 [NC,L] //for urls like localhost/notice/all/page/1
You have ?$
after the /
but it should be after the regex class
Upvotes: 2