Help in creating the . htaccess file

Asked

Viewed 77 times

-1

Hey, fellas, good afternoon. I’ve been trying for days to create a nice . htaccess, but we’re having some difficulties.

Here are examples of what I need, remembering that everything needs to be in the same URL.

1) Whenever the user accesses the website I want to add a "/home/" at the end of the URL.

Antes: http://app.meusite.com/ 

Depois: http://app.meusite.com/home/

2) I want all Urls to be removed from ". php".

Antes: http://app.meusite.com/login.php

Depois: http://app.meusite.com/login/

3) I want all Urls to be as follows:

Before:

http://app.meusite.com/usuario-adicionar.php

http://app.meusite.com/usuario-editar.php

http://app.meusite.com/usuario-excluir.php

Afterward:

http://app.meusite.com/usuario/adicionar/

http://app.meusite.com/usuario/editar/

http://app.meusite.com/usuario/excluir/

There is only one observation to be taken into consideration...

Because the whole site is multi-language, I need all pages to accept the get parameter which will be LANG=LANGUAGE (Ex.: lang=en_US)

So all of the above URLS must accept GET as well, and I would like it to be as follows:

http://app.meusite.com/index.php?lang=en_US
http://app.meusite.com/home/en_US/

http://app.meusite.com/login.php?lang=en_US
http://app.meusite.com/login/en_US/

http://app.meusite.com/usuario-adicionar.php?lang=en_US
http://app.meusite.com/usuario/adicionar/en_US/

http://app.meusite.com/usuario-editar.php?lang=en_US
http://app.meusite.com/usuario/editar/en_US/

http://app.meusite.com/usuario-excluir.php?lang=en_US
http://app.meusite.com/usuario/excluir/en_US/

Like I’m doing:

Options -MultiViews
Options +FollowSymLinks
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$

RewriteRule ^home\/?(.*)\/?$ index.php?lang=$1 [L]
RewriteRule ^([^/]*)\/?(.*)\/?$ $1.php?lang=$2 [L]
RewriteRule ^([^/]*)\/([^/]*)\/([^/]*)\/?$ $1-$2.php?lang=$3 [L]

I hope you can understand my doubt.

From now on, thank you all very much.

Hug!

  • Related question: http://answall.com/questions/75963/url-amig%C3%A1vel-utilizando-htaccess/75970#75970

1 answer

0

You can only use this htaccess =

RewriteRule . /index.php [L] 

And treat all logica in this index.php, using the command =

$url = explode("/", $_SERVER["REQUEST_URI"]);

Access a url and print on the variable $url that you will understand better, ai within the ifs that you will do within each url, you give a include on the page that will be opened.

Another way to do it is by making an htaccess rule for each url using regular expressions.

Browser other questions tagged

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