skip to Main Content

So for two days I can not understand why this won’t work…:

  Options -Indexes 
  Options +FollowSymLinks
  RewriteEngine On
  RewriteRule ^advice/([a-zA-Z]+)/([0-9]+)/$ advice.php?advice=$1&id=$2

Obviously .htaccess is allowed since I am not able to directory open folders, but why doesn’t the link work?

2

Answers


  1. Try turning off multiviews so the server doesn’t try and search for that as a file. In addition add the conditions so that it knows it’s not looking for a real file or directory it’s trying to serve and make the trailing slash optional.

      Options -Indexes +FollowSymLinks -MultiViews
      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^advice/([a-zA-Z]+)/([0-9]+)/?$ /advice.php?advice=$1&id=$2 [L]
    
    Login or Signup to reply.
  2. Does your RewriteRule redirect to an existing file?
    Try this, it works for me

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . /test2/test.php
    
    • http://example.com/test2/.htaccess shows the location of the .htaccess file
    • http://example.com/test2/test.php is a direct link
    • http://example.com/test2/testX4XX opens the same test.php file using rewrite
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search