Jump to content


Photo

mod_rewrite help


  • Please log in to reply
25 replies to this topic

#21 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 11 November 2005 - 03:33 AM

Talking to my host about the PHPSESSID. As to my other question...it didn't work. What I want is for the url:

http://www.netgeekz....s.php?article=1

To be changed to

http://www.netgeekz.net/news/1/

However I don't want to do that manually myself with each news post. I want every url to automatically be done. And example:

http://www.netgeekz....s.php?article=1 Changes to http://www.netgeekz.net/news/1/ Automatically

http://www.netgeekz....s.php?article=2 Changes to
http://www.netgeekz.net/news/2/ Automatically

And so on and so forth.

#22 neylitalo

neylitalo
  • Staff Alumni
  • Advanced Member
  • 1,854 posts
  • LocationMichigan, USA

Posted 11 November 2005 - 03:38 AM

I can give you a start - but not much else :X

http://httpd.apache....writeguide.html
http://nealylitalo.net - My personal website, and home of The Netizen's Journal.

#23 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 11 November 2005 - 03:49 AM

As to my other question...it didn't work.

What are you referring to?

http://www.netgeekz....s.php?article=1

To be changed to

http://www.netgeekz.net/news/1/

However I don't want to do that manually myself with each news post. I want every url to automatically be done. And example:

http://www.netgeekz....s.php?article=1 Changes to http://www.netgeekz.net/news/1/  Automatically

ModRewrite manipulates the request sent by the client. What you seem to be asking to do, is to manipulate your script's output similar to what PHP does when it adds the "session id" to the end of links etc.

Unless you modify PHP or Apache itself, I don't know of a way to accomplish that. To be clear however, I'm assuming that when you say you don't want to do it manually. You mean you don't want to go through your scripts, modifying the places where you output links(<a href="">)

EDIT: Actually I forgot about the output control functions that would allow you to modify the script's output

#24 Cook

Cook
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts
  • LocationSingapore

Posted 11 November 2005 - 06:00 AM

http://www.netgeekz....s.php?article=1 Changes to http://www.netgeekz.net/news/1/  Automatically

http://www.netgeekz....s.php?article=2 Changes to
http://www.netgeekz.net/news/2/ Automatically

And so on and so forth.

View Post


I've reworked my suggestion now that I understand better what you need. But again you'll have to have your host put this into an .htaccess for you if they don't allow you to do it yourself.

RewriteEngine On
RewriteRule ^/news\.php\?article=(.*) http://www.netgeekz.net/news/$1/ [R=301,L]

Cook

#25 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 11 November 2005 - 01:13 PM

That did the trick. Thanks all.

#26 Cook

Cook
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts
  • LocationSingapore

Posted 11 November 2005 - 02:10 PM

Good one. You're welcome.
Cook




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users