5

I have the file structure

index.php
.htaccess
news/index.php
news/.htaccess

First .htaccess:

RewriteEngine On
RewriteBase /

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

RewriteCond %{REQUEST_URI} !^/news/
RewriteRule . /index.php [L]

Second (news/.htaccess)

 RewriteEngine On
 RewriteRule . /index.php

Request http://test.t/news/news/61 the handles first index.php but I need to do it the second

I tried a few more options for the first .htaccess, but it did not succeed

1 Answer 1

3

Check your Apache config file (httpd.conf) and make sure the directory you are using for your site includes the AllowOverride option.

Example:

<Directory "/Applications/MAMP/htdocs">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
5
  • Is the http://test/news/news/61 using the wrong index.php? what does "did not succeed" mean?
    – Levi
    Dec 2, 2012 at 20:24
  • yes, second receives a request, only http://test/news/ without params ( news/61 ). Any other requests received first.
    – RuZk
    Dec 2, 2012 at 21:12
  • It sounds like it's doing exactly what you told it to do. Your combined .htaccess says for the url test/news/news/61, it should open /index.php and pass no params. If you want it to use /news/index.php, then you should edit your second .htaccess to say RewriteRule . index.php NOT /index.php. Do you need the url parts in your parameters?
    – Levi
    Dec 2, 2012 at 21:19
  • if you need the article number as a param, use something like: RewriteRule news/([0-9]+) index.php?articleId=$1 that uses a regex to match news/### and appends the article number to the url. See httpd.apache.org/docs/trunk/rewrite/remapping.html
    – Levi
    Dec 2, 2012 at 21:30
  • Parsing of the parameters involved in Yii, it was necessary to send them to him. Thanks!
    – RuZk
    Dec 2, 2012 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.