Rewrite module in . htaccess [split by folder]

Asked

Viewed 71 times

0

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

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

in html is 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, becomes a crazy bagasse, I have checked the headers and they are all absolute. what could be?

  • I edited the answer give a look http://answall.com/a/180099/3635

  • Did the answer solve your problem? Could you tell us what happened?

1 answer

0

The CSS folder won’t work if you don’t make the correct notes, I recommend you try using the address in all Csss with / in the 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 the CSS folder has to be outside the folder ./atacado, if you are inside you will be embarrassed when using the folder ./mercado, if you want to keep inside the folder ./atacado not working you can try to use the tag <base> within the ./mercado/index.php thus:

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

Of course if you’re wearing one include ...; to add the header maybe it’s better to use the absolute path as I mentioned above.


It’s probably because you created a folder called ./atacado, note also 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 on ./mercado/index.php does not exist, I believe you actually want to point everything to index.php which 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 market and to a folder called wholesale, then you should make sure that both exist and that they are in minuscule letters (if like-Unix), the structure expected by your .htaccess must be this:

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

You should also check if there is no other . htaccess inside the "market" and "wholesale" folders and also check if you have not forgotten to add RewriteEngine On

Browser other questions tagged

You are not signed in. Login or sign up in order to post.