Shinyshell Community Forums > Coding >
Querystring HALP


[1]


May 23 02009, 23:55 GMT
Peter*
A Pythonic One

Peter's avatar
Location: US
Post count: 99

Using .htaccess, how do I replace (for example) http://oopsie.com/index.php?id=folder/page with http://oopsie.com/folder/page, as Shinyshell and many other sites are set up? :D

May 24 02009, 12:23 GMT
Nick^
merciful justice

Nick's avatar
Location: Brisbane, Australia
Post count: 78
au
Oooh yay. .htaccess is awesome. :D
 RewriteEngine on
 
 #Make it so that /index.php?id=folder/page is /folder/page
 RewriteRule ^([A-Za-z0-9_-]+)$     index.php?id=$1
 
RewriteEngine on

#Make it so that /index.php?id=folder/page is /folder/page
RewriteRule ^([A-Za-z0-9_-]+)$ index.php?id=$1
]]>


I'm pretty confident that that code will work.
______________________________
Lazurane

May 24 02009, 13:53 GMT
Peter*
A Pythonic One

Peter's avatar
Location: US
Post count: 99

A couple of problems. My page, index.php?id=layouts/index doesn't work like this .../layouts/index. Also, ?id=tutorials/table-layouts ~ ../tutorials/table-layouts doesn't work...

It seems that if they're in a different folder it refuses to work.

May 25 02009, 07:04 GMT
Nick^
merciful justice

Nick's avatar
Location: Brisbane, Australia
Post count: 78
au
Hm... That doesn't make sense. Does everything else work?
______________________________
Lazurane

May 26 02009, 19:22 GMT
Kthar
Krme jedno bezglavo

Kthar's avatar
Location: kroatie
Post count: 106
hr
Alright, I waited long enough for you, Lec, to post a reply and unravel the mystery, but I just have to post a reply here or it might look as if I'm not doing anything.

May 26 02009, 21:33 GMT
Peter*
A Pythonic One

Peter's avatar
Location: US
Post count: 99

You can observe for yourself... http://z-design.jenviousity.com ; almost all the pages are found on the nav. :D

May 27 02009, 06:49 GMT
Nick^
merciful justice

Nick's avatar
Location: Brisbane, Australia
Post count: 78
au
Try this then, it's a bit hacky though:

 
 RewriteEngine on
 
 
 
 #Make it so that /index.php?id=x is /x (x = string)
 
 RewriteRule ^([A-Za-z0-9_-]+)$     index.php?id=$1
 
 #Make it so that /index.php?id=x/y is /x/y (x & y = one string)
 
 RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$   index.php?id=$1$2
 

RewriteEngine on



#Make it so that /index.php?id=x is /x (x = string)

RewriteRule ^([A-Za-z0-9_-]+)$ index.php?id=$1

#Make it so that /index.php?id=x/y is /x/y (x & y = one string)

RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ index.php?id=$1$2
]]>

______________________________
Lazurane

May 27 02009, 10:18 GMT
lec**
Supra stultitiam

lec's avatar
Location: Varaždin, Croatia
Post count: 173

It's not hacky, that's how I would do it.

.htaccess can cause unexpected glitches, so it's best to limit the rewriting to a minimum.

Also, Nick, you have an error. The last line should be:

 RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$   index.php?id=$1/$2
 
RewriteRule ^([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ index.php?id=$1/$2
]]>


Also, fixed some problems with the bbcode parser (code now displays nicely)

May 27 02009, 11:40 GMT
Nick^
merciful justice

Nick's avatar
Location: Brisbane, Australia
Post count: 78
au
Hmm... I just thought it wasn't working because I was doing something stupid - hence why I said it was "hacky". And, at the time, I thought it was correct, so it was a stupid mistake as opposed to an error.

And, I was about to mention that annoying bbcode code stretching thing.
______________________________
Lazurane

May 27 02009, 21:13 GMT
Peter*
A Pythonic One

Peter's avatar
Location: US
Post count: 99

Gasp! It works. I should learn a little bit more about this stuff. Thanks for your help, Nick and Electron!

May 27 02009, 21:18 GMT
lec**
Supra stultitiam

lec's avatar
Location: Varaždin, Croatia
Post count: 173

Of course :)

If you need more comments/ideas/help with your site, do ask.

*closed* (to keep kthar from posting just to increase his postcount)


[1]



Forum Information
  Currently Active Members [detailed] (0 members and ? guests)
-
Forum Statistics
Topics: 0, Posts: 0, Members: 108.
Welcome to our newest member, adamthephantump
Most members online was 5, on August 28 2009, at 21:49:28.
Legend
    Forums with unread topics in them are indicated by a strong yellow colouring around the forum icon.
    Forums with no unread topics have the standard pale yellow colouring around the forum icon.
    Forums with a blue arrow icon will redirect you to a non-forum page.
    Locked forums have a little padlock by their icon. You won't be able to post in these forums.
Shinyshell Home | Contact | Staff List | Archive | Top 

Conventional Login

Don't have an account? You may want to create one.

OpenID Login
OpenID login and registration is usable, but not finished.
What is OpenID?
Search

(advanced search)
Site Stats
  Total members: 108
  Latest member: adamthephantump
  Members currently online: 0
  Most online: 5 - Aug 28, 2009 (21:49)
  Front page hits: 88114
Developer info
  Site version: 3.5 Alpha
  16 queries - 9 templates
Under the Spotlight
Collide Site
Collide make fabulously dreamy electronic-industrial music, they're one of my favourite bands! Give them a chance to take control of your life - myspace | youtube - "Euphoria".

Collide Site - Hits: 4924

5/5 (2) | Rate this site?