简体   繁体   中英

.htaccess seo url rewrite problem with url end

I have a blogs page, and I want my urls to be like www.example.com/blogs/something-new/17 so I wrote below lines to .htaccess

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule  ^(.*)/$ $1.php

#SEO URL
RewriteRule ^blog/([0-9a-zA-Z-_]+)/([0-9a-zA-Z-_]+) blog-details.php?blogs_slug=$1&blogs_id=$2 [L,QSA]

Now, when I enter to example.com/blog/something-new/19 everything is fine, but I can keep writing like

example.com/blog/something-new/19/asdasfdsfas/asdasdsad

and it still shows the page, so how can I tell .htaccess to not to accept any more paramaters?

$ denotes the end of a regular expression test string. Add $ to rule, changed line:

#SEO URL
RewriteRule ^blog/([0-9a-zA-Z-_]+)/([0-9a-zA-Z-_]+)$ blog-details.php?blogs_slug=$1&blogs_id=$2 [L,QSA]

Then this address is not matched: example.com/blog/something-new/19/asdasfdsfas/asdasdsad but example.com/blog/something-new/19 match and works fine.

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