Home Friendly URL for multiple and long queries
Reply: 0

Friendly URL for multiple and long queries

user10004
1#
user10004 Published in September 19, 2018, 3:17 am

I tried a few different questions:

  1. php - .htaccess make URL user friendly for multiple and dynamic parameters
  2. .htaccess for friendly URL with multiple variables
  3. User-friendly URLs instead of Query Strings?

The questions above were not useful, so I began to develop an alternative, but my code is returning an 404 error with multiple requests(code1), and with one request worked well(code2) So:

(code1) - DonĀ“t Work - Multiple Resquest (code2) - Work Fine - Single Request

Code1


    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /~loja/index.php?a=$1&genero=$2&material=$3&cor=$4&tamanho=$5&Ordenacao=$6 [NC,L,QSA]
    RewriteCond %{THE_REQUEST} ^.*/index\.php 
    RewriteRule ^(.*)index.php$ /~loja/$1/$2/$3/$4/$5/$6 [R=301,L]  
    DirectoryIndex index.php

Now see the Correct Code:

Code2


    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9_-]+)$ /~loja/index.php?a=$1 [NC,L,QSA]
    RewriteCond %{THE_REQUEST} ^.*/index\.php 
    RewriteRule ^(.*)index.php$ /~loja/$1 [R=301,L]  
    DirectoryIndex index.php

What is wrong with (code1)?

share|improve this question
  • @anubhava if u can help me :) – Bruno Pinna Jan 9 '17 at 15:13
  • What are the URLs you're trying to rewrite? Provide a few examples please including the ones that fail. – sepehr Jan 9 '17 at 15:40
  • Original URL: site.com/index.php?a=botas-infantil&genero=feminino&material=couro&cor=marrom&tamanho=24-25&Ordenacao=MenorPreco – Bruno Pinna Jan 9 '17 at 15:59
  • goal: site.com/botas-infantil/feminino/couro/marrom/tamanho/24-25/MenorPreco – Bruno Pinna Jan 9 '17 at 16:00
  • With the code 2 work´s perfect, but add more request call error 404 – Bruno Pinna Jan 9 '17 at 16:01

1 Answer 1

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308042 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO