problem with friendly URLs and session variables

0

I have a web that manages a session variable in all the modules, this helps me to recognize the user that this "logged in" I have to change the normal to friendly url's, and I am helped by the RewriteRule. for the moment I managed to generate the friendly url with everything and the session made staying like this:

http://mi-sitio.com/inicio/jlllURL3Hf/

Where "jlllURL3Hf" is extracted from the DB as the session already "logged in" ok, while the session exists and the variable is being collected by the pages, there is no problem the problem is preceded, at the moment I need to see the page without the session done, as any user who enters for the first time, by not having the variable made by the session, simply the friendly url does not work throwing a error 404 .

This is the way I have the .httaccess until now.

 RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f 


RewriteRule acerca/(.*)/(.*) empresa.php?scid=$1&id=$2
RewriteRule contact/(.*)/(.*) contacto.php?scid=$1&id=$2
RewriteRule inicio/(.*)/(.*) index.php?scid=$1&id=$2
RewriteRule tienda/(.*)/(.*) productos.php?scid=$1&id=$2
RewriteRule novedades/(.*)/(.*)/(.*) productos.php?scid=$1&id=$2&new=$3
RewriteRule promos/(.*)/(.*)/(.*) productos.php?scid=$1&id=$2&promo=$3
RewriteRule catalogo/(.*)/(.*) descripcion_producto.php?scid=$1&id=$2
RewriteRule preguntas_frecuentes/(.*)/(.*) faqs.php?scid=$1&id=$2

Obviously there is something more than devo add to the code of htaccess , but do not hit the spot.

    
asked by Falopy 21.08.2017 в 22:54
source

3 answers

0

RewriteRule about / (. ) / (. ) / $ company.php? scid = $ 1 & id = $ 2

You are missing "/ $" between the rule.

    
answered by 21.08.2017 в 23:38
0

Try adding this rule:

    RewriteRule ^p/(\w+)/?$ index.php?controller=$1 [L]

It works very well for me.

    
answered by 22.08.2017 в 20:35
0

Thank you very much for the help I received from you, the solution to my problem was the following: I made 2 separate rules for each case on the site, example

Rewriterule ^inicio$ /index.php 

In this specific line, the "start" URL should only refer to the index.php in case there is no session variable made. so that we will have: misitio.com/inicio

RewriteRule ^inicio/(.*)/(.*) index.php?scid=$1&id=$2

Here I am specifying that the session variable exists, made by the user the URL / home / ABC123 / will apply for the previous URL index.php? scid = ABC123 in this way I managed to make the url "friendly" for both cases.

    
answered by 22.08.2017 в 23:32