User-friendly URL with HTACCESS parameters

Asked

Viewed 945 times

0

I am passing the whole old site to url friendly and with it came several problems on the old site the url was that way

http://meusite/download/programa.php? title=Avast-free-Antivirus

and with the new url wanted it to stay that way

http://meusite/download/Avast-free-Antivirus

I entered HTACCESS and created these rules

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/download/([a-z0-9-]+)/([0-9]+)/?$ /download/programa.php?title=$1 [NC]

then when accessing http://meusite/download/Avast-free-Antivirus for the server I’m accessing the page http://meusite/download/programa.php? title=Avast-free-Antivirus

On the program page I check whether what is coming in the title variable is equal to any database title

so the url doesn’t work I don’t know if it’s because I did something wrong or if I can’t do it that way upon accessing http://meusite/download/Avast-free-Antivirus of the error Not Found

Not Found

The requested URL /download/Avast-free-Antivirus was not found on this server.

Apache/2.4.23 (Win64) PHP/5.6.25 Server at mega Port 80

says the page was not found

  • Try to fix this: ([a-Z0-9-]+), the hyphen is a character, if you do not put the backslash, you may be giving an error, and not allowing hyphenation.

1 answer

0

You did this:

RewriteRule ^/download/([a-z0-9-]+)/([0-9]+)/?$ /download/programa.php?title=$1 [NC]

But for what it seems to desire the right is this (and remove the / front of both download/):

RewriteRule ^download/([a-z0-9-]+)/?$ download/programa.php?title=$1 [NC]
  • yes I forgot to take this was from the second parameter of the url.php program? title=$&id=$2 plus right and how Voce falouRewriteRule /download/([a-Z0-9-]+)/? $ /download/program.php? title=$1 [NC] more still gives the error do not know what is wrong

  • @diogoDsa I think I figured it out, do it: RewriteRule ^download/([a-z0-9-]+)/?$ download/programa.php?title=$1 [NC] (see what I changed /download/ for download/)

  • 1

    now it worked all right fought for help

  • If the answer solved your problem mark it as correct please, if you do not know how to do read: https://pt.meta.stackoverflow.com/a/1079/3635

Browser other questions tagged

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