- - - - -

Stupid Apache RewriteRules's


  • Please log in to reply
6 replies to this topic

#1 completesite

completesite

    web developing political musician freak

  • Members
  • PipPipPip
  • 50 posts

Posted 30 January 2005 - 11:28 PM

OK. I googled. I yahooed. I read the stupid RewriteEngine manual. but I just can't get this to work.
What I want is a rule that is like the following, but won't break when you forget the slash in the URL:
CODE
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/$ \?page=$1

With the above code, I can type in "http://mysite.com/funpage/" and it is the same as "http://mysite.com/?page=funpage" but if I accidentally forget the slash at the end of the url, the server returns a 404 page.
I tried the below code but it returns a 500 page:
CODE
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ \?page=$1

I would like it if it could work either way--with or withour the trailing slash.
Any help is appreciated
smile.gif
user posted image

CompleteSite! Services - custom website desgin, CMS solutions, SEO services and more

#2 Chris

Chris

    Huge Orange

  • Members
  • PipPipPipPipPipPip
  • 925 posts

Posted 31 January 2005 - 01:44 PM

Simple, in the regex make it optional with a ?

CODE
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)/?$ \?page=$1

Chris Hasenpflug
http://chris.hasenpflug.us

#3 completesite

completesite

    web developing political musician freak

  • Members
  • PipPipPip
  • 50 posts

Posted 31 January 2005 - 02:30 PM

I tried that but it still returns a 500 server error no mater what url format I try.
Thanks for your help anyways.
user posted image

CompleteSite! Services - custom website desgin, CMS solutions, SEO services and more

#4 X-Tech

X-Tech

    Half eaten orange

  • Members
  • PipPip
  • 34 posts

Posted 31 January 2005 - 10:25 PM

Did you try CHMODing? I get the 500 error when I dont CHMOD my perl scripts. (755)

#5 Chris

Chris

    Huge Orange

  • Members
  • PipPipPipPipPipPip
  • 925 posts

Posted 01 February 2005 - 02:29 AM

QUOTE(X-Tech @ Jan 31 2005, 9:25 PM)
Did you try CHMODing? I get the 500 error when I dont CHMOD my perl scripts. (755)

View Post



A 500 error on perl scripts would be completely and totally unrelated to a .htaccess 500.  A 500 as a result of changes in .htaccess indicates an error with the rules.
Chris Hasenpflug
http://chris.hasenpflug.us

#6 completesite

completesite

    web developing political musician freak

  • Members
  • PipPipPip
  • 50 posts

Posted 03 February 2005 - 02:11 PM

Well I've been trying all sorts of things but to no avail. I know there has to a way though. help is appreciated.
user posted image

CompleteSite! Services - custom website desgin, CMS solutions, SEO services and more

#7 codefather

codefather

    Tiny Orange

  • Members
  • Pip
  • 9 posts

Posted 12 February 2005 - 02:13 AM

Try
CODE
RewriteRule ^([^/]*)/?$ \?page=$1





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users