php - .htaccess url rewriting not working? -



php - .htaccess url rewriting not working? -

i'll honest in saying have little experience .htaccess i've wanted remain away best can. however, i've wanted tidy urls , i've found it's possible through .htaccess , rewriting.

basically, want rewrite url like:

www.mysite.com/profile.php?id=48194

to like:

www.mysite.com/profile/48194

here's code have currently:

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php rewriterule ^profile/(.*)/$ profile.php?id=$1

the line i'm trying utilize on bottom, rewriterule ^profile/(.*)/$ profile.php?id=$1. rest used remove page extensions urls. i've changed $1 $2 thinking perhaps conflicting code above, nil changed.

i removed code except rewriteengine on , lastly line thinking maybe codes conflicting but, again, nil changed or worked. rest of code work, removing extensions urls is, know rewrite thing on.

could seek break downwards , explain did wrong , how works? providing working illustration of thing i'm trying accomplish?

thanks in advance!

change order of rules , utilize multiviews option. alternative multiviews used apache's content negotiation module runs before mod_rewrite , and makes apache server match extensions of files. /file can in url serve /file.php.

rewriteengine on rewritebase / rewriterule ^profile/([^/]+)/?$ profile.php?id=$1 [l,qsa,nc] rewritecond %{request_filename} !-d rewritecond %{document_root}/$1\.php -f [nc] rewriterule ^(.+?)/?$ $1.php [l]

php apache .htaccess mod-rewrite url-rewriting

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -