RewriteEngine on RewriteRule ^/post/([0-9])/$ index.php?post=$1 [L] Options -Indexes Here is my rule, I try to go to the site localhost / post / 1/404 says, maybe in the rule I wrote something wrong please help plz = 3
RewriteEngine on RewriteRule ^/post/([0-9])/$ index.php?post=$1 [L] Options -Indexes Here is my rule, I try to go to the site localhost / post / 1/404 says, maybe in the rule I wrote something wrong please help plz = 3
The first RewriteRule is passed the path from the place where the .htaccess is located to the requested file. This line never starts with "/".
Thus, in RewriteRule you will have post/1/ (without a slash in the beginning), which does not coincide with your regularization.
To make it work, you need:
RewriteBase / to avoid redirect artifacts.Total should be:
RewriteEngine on RewriteBase / RewriteRule ^post/([0-9])/$ index.php?post=$1 [L] [0-9] you can use \d . And in order to be able to specify not only a number from 0 to 9 , but generally any, you can use \d+ . - user194374Source: https://ru.stackoverflow.com/questions/612210/
All Articles