1

I have been exploring this issue for the first time and I am struggling big time.

I have a file called home.php and wanted the url localhost/home to point to this.

I have the following:

RewriteEngine On
RewriteRule ^/home /home.php [L]

Can anyone figure out what I am doing wrong?

Eineki
  • 14,773
  • 6
  • 50
  • 59
John Doe
  • 836
  • 2
  • 10
  • 17

2 Answers2

4
RewriteEngine On
RewriteRule ^home$ /home.php [L]
  • Hi, I have tried this also but still getting the "Internal Server Error" error. I read below about the infinite loop, I'm not sure why it is entering it? – John Doe Jul 25 '11 at 11:56
  • Hi guys, thank you for all the help. I figured out that I had not enabled mod_rewrite opps(although I was pretty sure I had). The rewrite rule is now working. Thanks everyone! – John Doe Jul 25 '11 at 12:00
  • How do you redirect a user when they type: example.com/profile/edit/123 I want it to redirect to the following: example.com/profile.php?action=edit&&id=123 – John Doe Oct 18 '11 at 12:25
  • RewriteRule ^/profile/edit/(.*)$ /profile.php?action=edit&id=$1 [L] –  Oct 18 '11 at 12:31
1

Remove the trailing slashes

RewriteRule ^home$ home.php [L]
Eineki
  • 14,773
  • 6
  • 50
  • 59
  • Hi Eineki, Thanks for the response. I tried that but get "Internal Server Error" error message :( Is there something wrong with my set up? – John Doe Jul 25 '11 at 11:50
  • You have infinite rewrite loop. Add `$` at the end of pattern, e.g. `RewriteRule ^home$ home.php [L]` – LazyOne Jul 25 '11 at 11:53
  • @LazyOne Added, by the way, is not [L] bailing out from the rewriter engine as soon the rule is applied? – Eineki Jul 25 '11 at 12:20
  • @Eineki See my explanation to this question: http://stackoverflow.com/questions/6797998/rewriterule-last-l-flag-not-working/6800150#6800150 – LazyOne Jul 25 '11 at 12:26