Question

I have a very strange problem in my current custom PHP MVC project. If a controller methodname contains show (fx show_album), apache throws a 404 page not found?

Du you have any ideas why this happens?

.htaccess:

#mod_rewrite start
Options +FollowSymLinks

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z]*)/?([a-zA-Z]*)?/?([a-zA-Z0-9]*)?/?$ index.php?controller=$1&action=$2&id=$3 [QSA,L]
#mod_rewrite end

Btw. it works with normal get request in url (like index.php?controller=profile&action=show_album&id=1

Was it helpful?

Solution

Your problem is likely not to be the word show and more likely to be the underscore in show_album - your patterns in htaccess won't match underscores.

Try the following patterns with underscores added.

#mod_rewrite start
Options +FollowSymLinks

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z_]*)/?([a-zA-Z_]*)?/?([a-zA-Z0-9_]*)?/?$ index.php?controller=$1&action=$2&id=$3 [QSA,L]
#mod_rewrite end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top