简体   繁体   中英

.htaccess rewriting won't work or gets overwritten

I have the following url that needs to get rewritten with .htaccess For example I'm gonna use a news section of a website.

www.example.com/news/               -works
www.example.com/news/latest/        -works
www.example.com/news/1/this-is-news -does not work

This is a section of my current .htaccess that is used for the "news" section.

RewriteRule ^news/? index.php?view=news [L]
RewriteRule ^news/([^/\.]+)/([0-9]+)/?$ index.php?view=news&task=$1&page=$2 [L]
RewriteRule ^news/([0-9]+)/?$ index.php?view=news&id=$1 [L]

try this for your last entry:

^news/([0-9]+)/[0-9a-z\-]*$

it'll fix it so that any numbers, letter, dashes in the last slash will be caught, so it'll match your example, at least.

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