php - htaccess mod_rewrite rules combination issue -


i'm newbie in apache, it's basic question couldn't solve using questions or links.
tried change url using .htaccess , had 2 purposes;

  1. hide .php extension
  2. change querystring somefile.php?id=bar somefile/id/bar bar number or mixed string t51-3.
    querystring http://localhost/payment/theme/ticket?id=770314 want change http://localhost/payment/theme/ticket/id/770314 or
    http://localhost/payment/theme/ticket/770314

i found code:

options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  # externally redirect /dir/foo.php /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l,nc]   ## internally redirect /dir/foo /dir/foo.php rewritecond %{request_filename}.php -f [nc] rewriterule ^ %{request_uri}.php [l] 


in stackoverflow.com/this_question

this working nice didn't solve second issue.
so, searched while in site , others , did find sample codes 1 :

rewriterule ^([a-za-z0-9_-]+)-([0-9]+)$ ticket.php?id=$2 

or

rewriterule ^(.*)$ /ticket.php?url=$1 [l] 

and etc...

but none of these didn't work me.
of them make server done , don't have affect @ all. please guide me right way...
looked @ these questions:
htaccess rewrite query string

how change query string parameters name using .htaccess?

how can use .htaccess hide .php url extensions?

and these links:
http://simonecarletti.com/blog/2009/01/apache-query-string-redirects/
https://wiki.apache.org/httpd/rewritequerystring

update :
site strucure: site structure
there htaccess important folders, like, forms, db, classes etc...
site pages in theme folder, can see in picture.
in root htaccess, there's 2 lines auto start sessions.

, added code theme's htaccess.
thanks in advance

you can use code in

options +followsymlinks -multiviews rewriteengine on rewritebase /payment/theme/  # externally redirect /dir/foo.php /dir/foo rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php\?(\w+)=([^\s&]+)\s [nc] rewriterule ^ %1/%2/%3? [r,l]  rewritecond %{the_request} ^[a-z]{3,}\s([^.]+)\.php [nc] rewriterule ^ %1 [r,l]  # handle http://localhost/payment/theme/ticket/id/770314 rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(\w+)/([\w-]+)/([\w-]+)/?$ $1.php?$2=$3 [l,qsa]  ## internally redirect /dir/foo /dir/foo.php rewritecond %{request_filename}.php -f [nc] rewriterule ^(.+?)/?$ $1.php [l] 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -