Jump to content

mod_rewrite - some problem with this method

- - - - -

  • Please log in to reply
3 replies to this topic

#1
AdrianWierciochPHP

AdrianWierciochPHP

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Hi!

I will have write some engine sending e-mails so I have to write some .htaccess file. I want rewrite this address: test.local/index.php?c=$controller&m=$method to something like it: test.local/controller/method/

I have loaded mod_rewrite module. Please help me!

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I believe something like this is what you want:
RewriteEngine on
RewriteCond $1 != index.php[FONT=Tahoma]
[/FONT]RewriteRule ^([^/]*)/([^/]*)$

You can of course limit it to words, digits or whitespace with \w, \d or \s instead of the whole segment ([^/]*)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
AdrianWierciochPHP

AdrianWierciochPHP

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
It isn`t working. When I access http://test.local/adrian/wiercioch/ to browser, prints me error:

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.2.14 (Ubuntu) Server at test.local Port 80

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Oh I apologize, I forgot to write what it should be rewritten to. Try this:
RewriteEngine on
RewriteCond $1 !=index.php
RewriteRule ^([^/]*)/([^/]*)$ /index.php?c=$1&m=$2 [L,QSA]

Ensure you check Apache's error logs in case there is an error, it should tell you.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users