user1616846
user1616846

Reputation: 191

mod_rewrite and {QUERY_STRING}

Changed my url from

http://www.website.com/b.php?n=45&t=example

to this

http://www.website.com/45/example

by using this mod_rewrite

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)/(.*) /b.php?n=$1&b=$2 [L,QSA]

How do I get my query strings to still work because I want to use $_GET

echo '<img src="gifs/' . $_GET["t"] . '/' . $_GET["n"] . '.gif">';

Upvotes: 0

Views: 184

Answers (1)

Kalaiyarasan
Kalaiyarasan

Reputation: 13374

You can use the following .htaccess code for sending the full url to the b.php file and there you can split the url using the explode function and can get the query strings separately

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/* b.php?url=%{REQUEST_URI} [L,NC,QSA]

Upvotes: 1

Related Questions