Jump to content

mod_rewrite and $_GET


meany

Recommended Posts

i need some help with mod_rewrite. check this out:

 

# CREATE REWRITE OPTIONS
Options +FollowSymLinks

# TURN THE REWRITE ENGINE ON
RewriteEngine on

# WRITE PARAMETERS TO THE INDEX URL UNLESS REQUESTED URL IS A DIRECTORY OR FILE.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule page/(.*) index.php?$1
RewriteRule ^add/([^/\.]+)/?$ index.php?add=$1 [L]
RewriteRule ^edit/([^/\.]+)/?$ index.php?edit=$1 [L]

 

 

edit/edit_character.php

$sql162 = mysql_query("SELECT * FROM players WHERE id = '{$_GET['id']}'");

 

right now the url is:

http://site.com/edit/character&id=1

the original is http://site.com/?edit=character&id=1

what i want is http://site.com/edit/character/1

The requested URL /edit/character/2 was not found on this server.

The requested URL /edit/character/id/2 was not found on this server.

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/138619-mod_rewrite-and-_get/
Share on other sites

Try this, substitute 'index' and 'index.php' for the file that is calling the id

 

Options +FollowSymLinks

RewriteEngine on

RewriteRule index/edit/(.*)/id/(.*)/ index.php?edit=$1&id=$2

RewriteRule index/edit/(.*)/id/(.*) index.php?edit=$1&id=$2

Link to comment
https://forums.phpfreaks.com/topic/138619-mod_rewrite-and-_get/#findComment-729222
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.