Pergunta

I have this problem very rarely and only on some hostings. Here is my .htaccess for my custom framework:

Options -Indexes

ErrorDocument 403 /application/views/403.htm
ErrorDocument 404 /application/views/404.htm

RewriteEngine on
RewriteRule ^index\.php$ index.php [L]

.
.
.

RewriteRule ^([\w-]+)/([\w-]+)/(.+)$ index.php?q_controller=$1&rq_action=$2&rq_param=$3 [L]
RewriteRule ^([\w-]+)/([\w-]+)$ index.php?rq_controller=$1&rq_action=$2 [L]
RewriteRule ^([\w-]+)/?$ index.php?rq_controller=$1 [L]

These last 3 rows that defines controllers, views and params just wont work on some hostings, and all the rest is working fine so mod_rewrite is enabled obviously. If I change them to this it works, but that is not what I need:

RewriteRule ^(.+)/(.+)/(.+)$ index.php?rq_controller=$1&rq_action=$2&rq_param=$3 [L]
RewriteRule ^(.+)/(.+)$ index.php?rq_controller=$1&rq_action=$2 [L]
RewriteRule ^(.+)/?$ index.php?rq_controller=$1 [L]

Any ideas? Are those hostings not supporting character class in .htaccess regex?

Thanks

Foi útil?

Solução

I am not an expert in url rewriting, but you can try two things:

  1. try to replace [\w-] by an explicit [a-zA-Z0-9_-]
  2. try to replace [\w-] by [^/]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top