cbass
cbass

Reputation: 2558

Multiple RewriteRules in htaccess

I cannot get my url rewriting to work. I have to root which works fine. But I'm trying to add another route and it doesn't work.

What I want is:

mydoma.in/

which routes to index.php

And then

mydoma.in/comments

which routes to page-with-comments.php

And this is my code so far:

# http://httpd.apache.org/docs/current/mod/core.html#errordocument
#ErrorDocument 404 /404.php
ErrorDocument 404 "Message"


RewriteEngine on
RewriteRule ^comment/(.*)$ page-with-comments.php/$1 [L]

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on

  RewriteBase /path/needed/

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule (.*) index.php/$1 [NC,L]

</IfModule>

Both routes also takes parameters.

Upvotes: 1

Views: 123

Answers (1)

anubhava
anubhava

Reputation: 784898

Your RewriteBase seems to be faulty.

Have your code like this in root .htaccess:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /

  RewriteRule ^comment/(.*)$ page-with-comments.php/$1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.+) index.php/$1 [L]

</IfModule>

Upvotes: 1

Related Questions