0

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

Mladen Janjetovic
  • 13,844
  • 8
  • 72
  • 82

1 Answers1

1

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 [^/]
Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125
  • Yes that will do also, but I am looking for some server setting that is different from other hostings, where this works perfectly. Something to put in .htaccess or to demand from hosting provider, because they are saying "It's not up to us, we have enabled mod_rewrite" – Mladen Janjetovic Jun 18 '13 at 10:48
  • In lack of detailed answer I will edit this answer and pronounce it as right one – Mladen Janjetovic Jul 04 '13 at 13:49