I have the following two rules for index.php:
RewriteCond %{THE_REQUEST} [1]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://localhost/ [R=301,L]
Now I would like to get a value of $_GET[show] from index.php?show=topUsers which is from http://localhost/topUsers
I tried the following, but it doesn’t work:
RewriteRule ^/$ /index.php?show=$1 [L]
thank you for your response. I will simply use RewriteRule ^topUsers$ index.php?show=topUsers [L].
I am not sure why I used RewriteCond %{THE_REQUEST} [1]{3,9}\ /index\.php\ HTTP/, I copied it long time ago from one of tutorial, maybe for some seo purposes. My DirectoryIndex is index.php (index.php is in main directory).
So I can simply delete this line and leave the following:
Q1. WHY use %{THE_REQUEST} for anything? Its format is so incredibly useless to mod_rewrite that I NEVER use it - {REQUEST_URI} is the basic variable that you should be using.
Q2. What is your DirectoryIndex? If it’s index.php and you’re directing to / which resolves to index.php, it SHOULD put you in a tailchase (LOOPY) mode!
Q3. WHICH way are you going? If /topUsers => index.php?show=topUsers, then that’s pretty simple:
Otherwise, you’re going from a request that Apache can serve to one Apache can’t: index.php?show=topUsers => topUsers. Of course, that CAN be done with:
Of course not! The $1 variable must be created to be used. IMHO, a quick look at the regex section then the sample codes of my signature’s tutorial may be of great assistance to you.