I have the following rewriterules in my .htaccess file:
RewriteRule ^page_edit_(.*) page_edit.php?page=$1
RewriteRule ^page page.php
If I go to /page_edit_12, for example, I see the content of page.php. But I want to see page_edit.php?page=12.
With the following rules, it gives the correct parameter. So if I go with this rules to /page_edit_12, I see the content of page.php?edit=true&page=12
RewriteRule ^page_edit_(.*) page.php?edit=true&page=$1
RewriteRule ^page page.php
Why I can't break the URL so it can reach a another file, also if a match with another URl is found (/page in /page_edit_12)?
Your regex pattern for the second rule matches "/page_edit.php" and rewrites it to /page.php,add a $ at the end of the pattern to restrict it to match /page only.
RewriteRule ^page_edit_(.*) page_edit.php?page=$1 [NC,L]
RewriteRule ^page/?$ page.php [L]
You should add the [L] - Last - Flag to your first line, so it will end the process in .htacces:
RewriteRule ^page_edit_(.*) page_edit.php?page=$1 [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With