5 Replies - 430 Views - Last Post: 06 September 2012 - 04:02 PM Rate Topic: -----

#1 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Mod rewrite using gets.

Posted 06 September 2012 - 02:27 PM

Ok so i have been trying to make it so when some one visits my website like so
myurl.com/blah
and then id like it to view myurl.com/post/get.php?id=blah but still show
myurl.com/blah in the url bar. So do a mod rewrite. Is there any way i can do this with out breaking my website ? Every time i try all my other pages start to break. Just need it to work when some one goes to that url...

Thank you in advance.

P.s i have tested a few thing using mod rewrite be for any every page on my website starts to break.

Is This A Good Question/Topic? 0
  • +

Replies To: Mod rewrite using gets.

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: Mod rewrite using gets.

Posted 06 September 2012 - 02:56 PM

Well, what'd you try? Here's something real quick for you to try, I'm by no means an "expert" or even to be considered good at mod rewrite, so I wouldn't use this in production ;)

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-zA-Z-]*)$ myurl.com/post/get.php?id=$1 [QSA,L]


(untested)
Was This Post Helpful? 0
  • +
  • -

#3 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Re: Mod rewrite using gets.

Posted 06 September 2012 - 03:07 PM

when i try that im getting a 404 page error.
Not Found
The requested URL /blah was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
for some odd reason even tho the post dir is there and the get.php is in side it...
I have tried a few mod rewrite scripts but get the same thing every time.
here is a example of one.
RewriteEngine On
RewriteRule ^([a-z]+)/([a-z\-]+)$ /$2.php [L]

i tryied to use that a few weeks ago and was hitting the 404 page...
Was This Post Helpful? 0
  • +
  • -

#4 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: Mod rewrite using gets.

Posted 06 September 2012 - 03:35 PM

can we see your file layout?
Was This Post Helpful? 0
  • +
  • -

#5 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Re: Mod rewrite using gets.

Posted 06 September 2012 - 03:42 PM

You mean you wanna see my index.php page or the dir of were my files are ???

I have a index.php and a post folder with get.php in. And then have a .http access file in the main root were the index.php is...

i do a simple redirect using mod rewrite
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.dreamincode.net/$1 [R=301,L]


to test if the mod rewrite is working and it works fine.. It redirects me to here on what ever page i go to on my root... but other mod rewrite codes will not work...
Was This Post Helpful? 0
  • +
  • -

#6 rpgmaker  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 224
  • Joined: 02-October 11

Re: Mod rewrite using gets.

Posted 06 September 2012 - 04:02 PM

Just a quick update i got it working now here is the working code to help any one else who is stuck with this problem.

Options +FollowSymLinks


RewriteEngine on


RewriteRule ^/?([-A-Za-z0-9]+)/?$ index.php?sectionname=$1 [L] 


You then can just go to yoururl.com/index.php ( i chose index.php but you can change it
and echo out
$_GET['sectionname'];


Then go to yoururl.com/test
and it will show test on the page :)
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1