简体   繁体   中英

how can i manage url using .htaccess in php?

i want to manage url of my website

right now its showing me www.computermall.co.in/product_details.php?prdid=34

but i want www.computermall.co.in/product_details/34

how can i do it?

i have tried this

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /computermall

# Get the URI-path directly from THE_REQUEST variable
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\s/(.*)\.php [NC]
# Strip the extension and redirect permanently
RewriteRule  .*   /%2   [R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.php  [NC]
# Map internally to the original resource
RewriteRule ^(.*)$ $1.php [L,QSA] 

Try this:

RewriteEngine On
RewriteRule ^product_details/prdid/([^/]*)$ /product_details?prdid=$1 [L]

Edit: removed leading slash

First of all your RewriteBase /computermall is confusing but i am assuming thats there because your domain is in a sub directory of another active domain/http server path.

Here is your htaccess

RewriteBase /
RewriteRule ^computermall/product_details/([^/]*)/([^/]*$ /computermall/product_details?prdid=$2 [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM