7
I’m trying to create a redirect with htaccess and I got it in the following way:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} !^/(?:index\.php|robots\.txt)$
RewriteRule (.*) http://meusite.com/novapasta/$1 [R=301,L]
</ifModule>
The problem that when I type in the URL any other file that is not index.php or robots.txt it plays to this folder.
Ex: sitemap.xml it is directing meusite.com/Novafolder/sitemap.xml and I don’t want that.
I tried to put:
RewriteCond %{REQUEST_URI} !^/(?:index\.php|robots\.txt|sitemap\.xml)$
But it does not accept and directs from root to /Novafolder/sitemap.xml folder
Even folders he’s directing.
Ex: meusite.com/imagens
for meusite.com/novapasta/imagens/
How can I stop it?
What I need:
So I always test in private mode and he still directs. I actually have a website that he had a querystring that makes the links stay
http://meusite.com/produto.php?produto=$1
http://meusite.com/produto
Now I want to throw everything into this new folder
http://meusite.com/novapasta/produto
Only with this redirect if I try to access:
http://meusite.com/sitemap.xml
, http://meusite.com/imagens/
and http://meusite.com/diretorioqualquer
he plays for:
http://meusite.com/novapasta/sitemap.xml
, http://meusite.com/novapasta/imagens/
and
http://meusite.com/novapasta/diretorioqualquer
The only ones he doesn’t play are index and robots and would like to play only what comes from produto.php?produto=$1
So I always test it in private mode and it still directs. I actually have a website that he had a querystring that makes the links stay
http://meusite.com/produto.php?produto=$1
Now I want to throw everything into this new folder
http://meusite.com/novapasta/produto
Only with this redirect if I try to access
http://meusite.com/sitemap.xml
http://meusite.com/diretorioqualquer
he plays for
http://meusite.com/novapasta/sitemap.xml
http://meusite.com/novapasta/imagens/
http://meusite.com/novapasta/diretorioqualquer
The only ones he doesn’t play are index and robots and would like to play only what comes from the product.php? product=$1
I answered briefly, but from what I understand it looks like you’re wearing a
.htaccess
without knowing exactly what you want, I mean you want one thing, but your htaccess is doing something totally different than what you need. Tell me you really want to block all urls and release just a few? Because if this is it, your htaccess is ok, but if not then your htaccess has no meaning for your project.– Guilherme Nascimento
I don’t really have much knowledge on . htaccess so I’m racking my brain with various tests
– rafaeloliveira
Tell me you really want to block all urls and release just a few?
– Guilherme Nascimento
Depends on the server has permission to configure htaccess, and nothing easy to set up, if it is Locaweb is claim support, recommend to use cPanel is useful to use and will help, and the IIS server can much trampo. Search for "URL friendly" can help.
– KingRider