friendly url rewrite

1

Hello, how are you?

I need the url of my homepage to look like this: link url of the home page is appearing like this: link

A second page appears as the initial page: link

I would like the second page to look like this: link ie I would hide the sourceId = 78902565 and in the location of categoryId = 5 there would appear super-offers.

On all other pages, the sourceId = 78902565 appears, I would like to hide it in a way that would not hurt my sales and in the location of categoryId the names of the respective categories appear, such as:

link link

I would like it to appear:

link link

  

My .htaccess looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

</IfModule>
  

My index.php looks like this:

<?php
     function getHome(){
    $url = (isset($_GET['url'])) ? $_GET['url']: ('home');           
        $url = array_filter(explode('/',$url));         
        $file = ('pgs/'.$url[0].'.php');

        if(is_file($file)){
               include $file;
        }else{ 
               include('pgs/'.'home'.'.php'); 
        };

        if((null== $file) || ('pgs/'.$url[0].'.php')== '' || ($_GET['url']) === false){
           include('pgs/'.'404'.'.php');  
               exit();      
        };       

     };
     getHome();
?>

Other pages like: contact and about work normally, just for the offers page I need friendly url (s).

Is it correct for these weird url (s) that appear?

Thanks in advance.

    
asked by anonymous 26.02.2018 / 19:28

2 answers

-1

Here in my .htacess it looks like this:

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php/?$ /$1 [L,R=301,NC,NE]

canonical solve? I know it's hard work ...

But I'm studying about ... And getting a better answer, I'll give you ...

    
27.02.2018 / 06:40
-1

Url ogirinal:

http://meusite.com.br/?sourceId=78902565&categoryId=10

Url rewritten:

http://meusite.com.br/categoryId/10

Rule:

RewriteRule ^categoryId/([^/]*)$ /?sourceId=78902565&categoryId=$1 [NC]

to leave in this format:

http://meusite.com.br/celulares

your url would need to be http://meusite.com.br?category=celulares

your url needs to receive the category by the name and not by the number as it is currently:

http://meusite.com.br/?sourceId=78902565&categoryId=celulares

  

To add sourceId simply change it this way:

     

RewriteRule ^([^/]*)/categoryId/([^/]*)$ /?sourceId=$1&categoryId=$2 [NC]

     

Original URL: http://meusite.com.br/?sourceId=78902565&categoryId=10

     

Url rewritten: http://meusite.com.br/78902565/categoryId/10

    
26.02.2018 / 20:09