Rehrite module in .htaccess [sort by folder]

0

I have two folders, when I add the function it takes only the first one, for example:

RewriteRule ^atacado/(.*)/(.*) atacado/index.php?estado=$1&cidade=$2 [NC,L]
RewriteRule ^mercado/(.*)/(.*) mercado/index.php?estado=$1&cidade=$2 [NC,L]

no html looks like this:

/atacado/SP/São+Paulo
/mercado/SP/São+Paulo

When clicking on / wholesale works correctly, now when I click on MARKET the css breaks, turns a mad bagasse, I have already checked the headers and they are all absolute. What could it be?

    
asked by anonymous 26.01.2017 / 14:57

1 answer

0

The CSS folder will not work if you do not make the right notes, I recommend that you try to use the address in all CSSs with / up front, like this:

<link href="/css/estilo1.css">
<link href="/css/estilo2.css">
<link href="/css/estilo3.css">

Or absolute path:

<link href="http://site/css/estilo1.css">
<link href="http://site/css/estilo2.css">
<link href="http://site/css/estilo3.css">

Remember that the CSS folder has to be outside the ./atacado folder, if you are inside you will get in the way of using the ./mercado folder, if you want to keep inside the ./atacado folder it does not work you can try use the <base> tag inside ./mercado/index.php like this:

<html>
<head>
<base href="/atacado/">
...

Of course, if you are using include ...; to add header it might be better to use the absolute path as I mentioned above.

It's probably because you created a folder called ./atacado , also note that you added the folders in the rewrite

atacado/index.php?estado=$1&cidade=$2 [NC,L] <-- antes do index.php tem a pasta atacado
mercado/index.php?estado=$1&cidade=$2 [NC,L] <-- antes do index.php tem a pasta mercado

Probably the folder ./mercado or the file in ./mercado/index.php does not exist, I think you really want to point everything to index.php that is in the same folder as .htaccess, so the correct one would be:

RewriteEngine On
RewriteRule ^atacado/(.*)/(.*) index.php?estado=$1&cidade=$2 [NC,L]
RewriteRule ^mercado/(.*)/(.*) index.php?estado=$1&cidade=$2 [NC,L]

Now if you really want to point to a folder called the market and to a folder named wholesale, then you should make sure that both exist and that they are in lowercase letters (if it is like-unix), the structure expected by your% should be this:

./
├── .htaccess
├── atacado/
|    └── index.php
└── mercado/
     └── index.php

You should also check that there is no other .htaccess in the "market" and "wholesale" folders and also check if you have forgotten to add .htaccess

    
26.01.2017 / 15:33