How do I modify a url with .htacess? [duplicate]

1

I have the url example.com/photo I would like to modify it for example.com/picture

Note I have access to .htacess and apache modules.

    
asked by anonymous 09.02.2015 / 04:22

1 answer

2

This article may help you URL Rewriting for Beginners .

Using what is shown in the article I believe the following code can be applied.

RewriteEngine On    # Turn on the rewriting engine
# Manda requisições com endereço de imagem para "foto.php" onde foto.php é o arquivo que 
# irá processar as requisições.
# NC informa ao apache que é case insensitive e L diz que caso esta regra seja usada as 
# demais não devem ser usadas.
RewriteRule    ^imagem/?$    foto.php    [NC,L]    

Also according to this article Redirecting the Web Folder Directory to another Directory in htaccess the code could be:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^imagem/(.*)$ /foto/$1 [R=301,NC,L] 
The R=301 informs that the request must return code 301 to report that there was a redirection, NC and L work in the same way as the previous one. The $1 is Basic regular expression and represents the capture of the first catch group of the regular expression, in this case the (.*)$ which basically is everything inserted after the image.

Try changing your file by adding this line and making sure that there is no rule before it is activated before and has the L directive, which would make it no longer active.

I hope this helps.

    
09.02.2015 / 05:23