0

I have encountered a problem, while implementing MVC design patterns for my website. I have a folder named "svce" inside the folder /www (which is my DOCUMENT_ROOT). I created a .htaccess file and wrote the following codes inside it:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$index.php?url=$1 [QSA,L]

Then I edited the httpd.conf file and uncommented the LoadModule rewrite_module modules/mod_rewrite.so.

Even after doing this, RewriteEngine is not working. When I try to access application using http://localhost/svce/blahblah.php, it gives me a default 404 error page.

IT should have shown me only the index page inside the /svce directory.

Bikash
  • 9
  • 3
  • I even restarted my apache server, I'm using wamp server – Bikash Sep 26 '12 at 10:35
  • 1
    What does "MVC is not working" mean? MVC is design patter and has nothing to do with URLs or routing. And on related not: "does not work" is not a valid error message. – tereško Sep 26 '12 at 10:41
  • What are you typing into the browser? – Brian Warshaw Sep 26 '12 at 10:53
  • @tereško, look at the question, I said, I wanted to implement MVC model for website, I said Im sorry if i am not able to make you understand, now please stop bugging me and help me solve this problem. – Bikash Sep 26 '12 at 10:59
  • when I'm typing: `http://localhost/svce`, it displays me index page, but when I type `http://localhost/svce/nofile`, then it gives me a 404 error message. – Bikash Sep 26 '12 at 11:00
  • @Bikash: This question has nothing to do with MVC. It's strictly a mod-rewrite issue. – Madara's Ghost Sep 26 '12 at 11:00
  • @MadaraUchiha, ok then, if thats the case, i accept it, now what? will you please help me to solve this problem or anyone is there left to say this has nothing to do with MVC? i said im sorry. – Bikash Sep 26 '12 at 11:02
  • @Bikash , [model](http://stackoverflow.com/a/5864000/727208) in MVC pattern is a layer. It is completely unrelated to any form of routing. – tereško Sep 26 '12 at 11:02
  • now i have unlinked the mvc from the question, now what? are you going to solve the problem or again i have to justify something? – Bikash Sep 26 '12 at 11:04

1 Answers1

3

You're missing a space:

# here -----------v
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

Without that space, the rule wants to rewrite a URI that looks like /something/$index.phpurl=$1 and rewrite it to [QSA,L], which is probably not a valid resource.

Additionally make sure you have AllowOverride All set in your server config.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • AllowOverride All in which file? Can you please specify? – Bikash Sep 26 '12 at 10:40
  • @Bikash Either in httpd.conf (server config) or in your vhost config file (which could be named any number of things, but probably ends with .conf). – Jon Lin Sep 26 '12 at 10:41
  • if its in httpd.conf, then I have already done that, and I kept the space there, still it cant help me. I don't even get 500 error, I only get the 404 default error, i should get the index page but nothing is really helping. – Bikash Sep 26 '12 at 10:43
  • @Bikash try adding `RewriteBase /` below the `RewriteEngine On` – Jon Lin Sep 26 '12 at 10:45
  • allowoverride is set to all, rewritebase also written, .htacess file seems to be Okay restarted apache server, but can't get this thing working. – Bikash Sep 26 '12 at 10:51
  • @tereško , ya i have already added the whitespace, i think apache is not responding to the .htacess file, whatever be the content on .htacess, it is not responding anything. – Bikash Sep 26 '12 at 11:09
  • The file is `.htaccess` (as I twice edited in your post). With two C's. – tereško Sep 26 '12 at 11:19
  • @Bikash And you're sure there is no `AllowOverride None` inside a `` block or anything in your config files? – Jon Lin Sep 26 '12 at 17:17
  • no, that was mistyped, it was .htaccess sorry. its solved now – Bikash Oct 01 '12 at 10:09