skip to Main Content

I’m trying to make pretty URL for my gallery page.
Main page index.php gets url parameters tabl(table) and meno(name) to see which gallery to be visible.
I have a link to gallery.

<a href="https://onlinegallery.online/index.php?tabl='.$table.'&meno='.$jmeno.'">'.$table.'</a>

URL to show gallery.
https://onlinegallery.online/index.php?tabl=gallery&meno=admin

I need to get https://onlinegallery.online/gallery/admin

I spent a lot of time but all i write to .htaccess not working.
For example.

RewriteEngine On

RewriteRule ^tabl/meno/([0-9]+)/([^.]+)$ index.php?tabl=$1&meno=$2

May there be a problem with the php code inside index.php? Code is for redirect page if there is no variable inside url and is also the main page of my gallery page.

if(!isset($_GET['meno'])){
header('location: ' . 'https://onlinegallery.online/index.php?tabl=gallery&meno=admin');
exit;
}

2

Answers


  1. Chosen as BEST ANSWER

    WORKS

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^([^/]+)/([^/]+)/$ index.php?tabl=$1&meno=$2 [L]
    Redirect /index.html /gallery/admin/
    </IfModule>
    

    On page where need to send variables to URL

    <a href="https://onlinegallery.online/'.$table.'/'.$jmeno.'/"
    

    On index.php i had to change all links to full URL

    <script type="text/javascript" src="https://onlinegallery.online/js/full.js"></script>
    

    Thank you all

    https://onlinegallery.online/admin/gallery/


  2. Are you saying you want to visit URL:

    https://onlinegallery.online/gallery/admin

    to get:

    https://onlinegallery.online/index.php?tabl=gallery&meno=admin

    Where:

    https://onlinegallery.online/%5Btabl%5D/%5Bmeno%5D

    if that is the case

    RewriteEngine On
    RewriteBase   /
    RewriteRule   ^(.*)/(.&)$  index.php?tabl=$1&meno=$2  [QSA,L]
    

    Remember if are not using httpd.conf base configuration file, and you are using .htaccess file, .ht* configuration must be turn on (with rewrite module included), and your directory must have configuration of AllowOverride for accepting rewrite command too.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search