LiveWire Peer Support Network

Printable Version of Topic "Apache and mod_rewrite"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- Computer Networking (http://www.golivewire.com/forums/forum-207-s-0.html)
---- Apache and mod_rewrite (http://www.golivewire.com/forums/peer-yaiaept-support-a.html)


-- Posted by ThugAngel at 12:30 pm on Aug. 25, 2008

So I wrote the following in a .htaccess file:
Code:

RewriteEngine on
RewriteRule ^games$ http://%{SERVER_NAME}/index.php?category=games [R]

The problem is that the address in the browser is replaced with 'http://localhost/index.php?category=games', when I want it to remain http://localhost/games/

Does anyone know how I can do this?

Thanks


-- Posted by memorexdl at 12:37 pm on Aug. 25, 2008

I are tarded dent esk meh


-- Posted by Tony327 at 12:38 pm on Aug. 25, 2008

I believe by having the http:// in the rewrite rule, that forces an address change. Try taking that off (and even the server name variable), and see if that works?


-- Posted by Tony327 at 12:41 pm on Aug. 25, 2008

(I've done work with htaccess and mod_rewrite on my own before, and have never had to have http://%{SERVER_NAME} in my rewrite rules to accomplish what I wanted to accomplish.)


-- Posted by Narfle the Garthok at 12:43 pm on Aug. 25, 2008

Quote: from ThugAngel at 12:30 pm on Aug. 25, 2008


So I wrote the following in a .htaccess file:
Code:

RewriteEngine on
RewriteRule ^games$ http://%{SERVER_NAME}/index.php?category=games [R]

The problem is that the address in the browser is replaced with 'http://localhost/index.php?category=games', when I want it to remain http://localhost/games/

Does anyone know how I can do this?

Thanks


Code:
RewriteRule ^games$ http://%{SERVER_NAME}/index.php?category=games

you are telling it to point to
http://localhost/index.php?category=games

http://www.ecauldron.com/web/design020.php

Read that it will help you understand where you went wrong.


-- Posted by ThugAngel at 12:46 pm on Aug. 25, 2008

If I don't put the http://%{REMOTE_HOST}/ I this error

http://localhost/C:/http/index.php?category=games

C:/http/ being where the server is. Also, my rewrite works, but I don't want the browser address to change.


-- Posted by Narfle the Garthok at 12:46 pm on Aug. 25, 2008

I see what your saying now.


-- Posted by Tony327 at 12:55 pm on Aug. 25, 2008

Quote: from ThugAngel at 3:46 pm on Aug. 25, 2008


If I don't put the http://%{REMOTE_HOST}/ I this error

http://localhost/C:/http/index.php?category=games

C:/http/ being where the server is. Also, my rewrite works, but I don't want the browser address to change.


This might not be relevant, but, why do you have the [R] flag? Have you tried taking it off, and seeing what that does?


-- Posted by ThugAngel at 12:58 pm on Aug. 25, 2008

Quote: from Tony327 at 3:55 pm on Aug. 25, 2008


Quote: from ThugAngel at 3:46 pm on Aug. 25, 2008

If I don't put the http://%{REMOTE_HOST}/ I this error  

 http://localhost/C:/http/index.php?category=games  

 C:/http/ being where the server is. Also, my rewrite works, but I don't want the browser address to change.


This might not be relevant, but, why do you have the [R] flag? Have you tried taking it off, and seeing what that does?



LOL that worked!! thanks! also when removing that I didn't need to specify the whole server.

Code:

RewriteEngine on
RewriteRule ^games index.php?category=games


-- Posted by Tony327 at 1:03 pm on Aug. 25, 2008

Quote: from ThugAngel at 3:58 pm on Aug. 25, 2008


Quote: from Tony327 at 3:55 pm on Aug. 25, 2008

Quote: from ThugAngel at 3:46 pm on Aug. 25, 2008

If I don't put the http://%{REMOTE_HOST}/ I this error

  http://localhost/C:/http/index.php?category=games

  C:/http/ being where the server is. Also, my rewrite works, but I don't want the browser address to change.


 

 This might not be relevant, but, why do you have the [R] flag? Have you tried taking it off, and seeing what that does?


 
LOL that worked!! thanks! also when removing that I didn't need to specify the whole server.

Code:

RewriteEngine on
RewriteRule ^games index.php?category=games


I'm glad it worked


www.golivewire.com