I have this rule in htacess:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]*)/?$ producto-test.php?stock=$1 [QSA]
But when I access to
http://www.example.com/
Redirect automatic to
http://www.example.com/?stock=
I have 2 files: producto-test.php, index.php
Always access to producto-test.php with this configuration in htacess
What can i do to access: http://www.example.com/
CodePudding user response:
Both of your quantifiers are optional in ^([a-zA-Z0-9_-]*)/?$
so it can match an empty string and append that as $1
in the url.
You can make the quantifier
for the character class [a-zA-Z0-9_-]
or perhaps a bit shorter [\w-]
See this page about the L flag as commented by anubhava if it should be the last processed rule.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-] )/?$ producto-test.php?stock=$1 [QSA,L]