0

My current .htaccess:

RewriteEngine On
RewriteBase /myproject/

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?r=$1 [QSA]

If I write:

/?r=page1 (Page1 is just an example in this context). : WORKS

/page1 : DOESN'T WORK, DISPLAYS 404 ERROR

What's wrong with my .htaccess?

9
  • Is that your entire .htaccess file? Commented Jul 19, 2015 at 11:09
  • @Anonymous I added the entire .htaccess file. Thanks for asking. Commented Jul 19, 2015 at 11:13
  • And are you visiting /myproject/page1? Commented Jul 19, 2015 at 11:16
  • @Anonymous /myproject/index.php, I pass like this, localhost/myproject/?r=page1 (this one works), however, if I do localhost/myproject/page1 it fails and 404 is thrown by IIS. Commented Jul 19, 2015 at 11:18
  • 1
    Yeah, I've just tested this and it's working fine. If you're not getting anything rewritten at all, check your file permissions, your file name, and ensure that the .htaccess file is in the root of your website. Commented Jul 19, 2015 at 11:25

1 Answer 1

1

The following line solved it:

RewriteRule ^([^?]*)$ index.php?r=$1 [QSA]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.