简体   繁体   中英

htaccess rewrite order id remove ?order_id but use slash

Been stuck with this question for hours. I've tried tons of things throughout the internet, but can't get it solved.

So, what I currently have is: https://example.com/order/index.php?order_id=12345

What I've been wanting to achieve is https://example.com/order/12345

My .htaccess file looks like this, and is located in the /order/ directory:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\d+)*$ .index.php?order_id=$1

I got this from another post on StackOverflow, but I can't seem to get it working.

I feel like I might be doing something wrong. I hope anyone is able to assist me here, have a great day guys!

check this out

RewriteEngine On

#RewriteBase /order/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
# n is no of length
RewriteRule ^([0-9]{n})$ index.php?order_id=$1 [QSA,L]

This is what exactly you need i guess.

#
RewriteEngine On
RewriteBase /
RewriteRule order(/)(.+)$ /index.php?order_id=$2 [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