I have a little problem, i use htaccess to rewrite my url. It works half.. I use in my htaccess:
RewriteRule ^admin$ index.php?page=admin [NC,L]
RewriteRule ^admin/$ index.php?page=admin [NC,L]
RewriteRule ^admin/?([a-zA-Z-]+)$ index.php?page=admin&subpage=$1 [NC,L]
RewriteRule ^admin/?([a-zA-Z-]+)/$ index.php?page=admin&subpage=$1 [NC,L]
#RewriteRule ^admin/?([a-zA-Z-]+)/?([a-zA-Z-]+)$ index.php?page=admin&subpage=$1&action=$2 [NC,L]
#RewriteRule ^admin/?([a-zA-Z-]+)/?([a-zA-Z-]+)/$ index.php?page=admin&subpage=$1&action=$2 [NC,L]
#RewriteRule ^admin/?([a-zA-Z-]+)/?([a-zA-Z-]+)/?([a-zA-Z-]+)$ index.php?page=admin&subpage=$1&action=$2&mode=$3 [NC,L]
#RewriteRule ^admin/?([a-zA-Z-]+)/?([a-zA-Z-]+)/?([a-zA-Z-]+)/$ index.php?page=admin&subpage=$1&action=$2&mode=$3 [NC,L]
This works:
http://example.com/admin/editArticle/
But when i do this i got a 404 not found..
http://example.com/admin/editArticle/editMode/22
The controller has the following:
if ($_GET['page'] == 'admin' && $_GET['subpage'] == 'editArticle' && $_GET['action'] == 'editMode' && !empty($_GET['mode'])) {
echo 'Edit mode LOADED!';
die();
//$this->_model->setTemplate('articleEditMode');
} elseif ($_GET['page'] == 'admin' && !empty($_GET['subpage'])) {
$this->_model->setTemplate($_GET['subpage']);
}
This is the button that i push to get to the page:
<a href="'.BASE_URL.'/admin/editArticle/editMode/'.$row['id'].'/">Edit article</a>
What do i wrong to get the error there? Even if i do a var_dump in the index. I cannot reach it. I get always a 404..
Try with:
RewriteRule ^admin/?$ index.php?page=admin [NC,L]
RewriteRule ^admin/([a-zA-Z-]+)/?$ index.php?page=admin&subpage=$1 [NC,L]
RewriteRule ^admin/([a-zA-Z-]+)/([a-zA-Z-]+)/?$ index.php?page=admin&subpage=$1&action=$2 [NC,L]
RewriteRule ^admin/([a-zA-Z-]+)/([a-zA-Z-]+)/([a-zA-Z0-9-]+)/?$ index.php?page=admin&subpage=$1&action=$2&mode=$3 [NC,L]
No need to add one with /$
and one without. You can use /?$
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.