How to make my URL more user friendly?

Asked

Viewed 166 times

2

I have the following URL:

www.site.com.br/www/login.php

And I wanted to leave her like this:

www.site.com.br/login

How can I do this through . htaccess?

  • Associated: https://answall.com/questions/25985/url-amig%C3%A1vel-com-htaccess? noredirect=1&lq=1

  • The list of possible duplicates is extensive... https://answall.com/search?q=url+amigavel

2 answers

0

Hello,

you can use mod_rewrite to do this.

1) Create a . htaccess file at the root of your server directory;

2) write RewriteEngine On in the first line of the file.

3) create a rule for redirecting the URL.

ex: Your URL: http://www.seusite.com.br/site.php?id=1&cod=novo
URL desired: http://www.seudominio.com.br/novo

Your file will have the line:
RewriteRule ^/novo$ /site.php?ind=1&cod=novo [NC]

It may be a bit confusing at first, but you can find more information about it here:
http://www.uolhost.uol.com.br/faq/v2/hospedagem/como-utilizar-o-modrewrite-para-conversao-de-urls-amigaveis-em-minha-hospedagem-linux.html#rmcl

and here too:
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

0

That rule should solve:

RewriteEngine ON
RewriteRule ^www/(.*)$ $1 [L,QSA]

"More details can be found" below:

  • The flag QSA, informs that only Query_string you can access them.
  • The flag L (last) is a flag to indicate that the current rule must be applied immediately, without considering other rules (i.e., it becomes independent).

Source

You can test her here.

Browser other questions tagged

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