简体   繁体   中英

How Do I redirect to php file with Htaccess

Is there a way to redierct a url to a php file based on one part of the url.

For example I have a url -

http://www.website.org/Cat/89/Diamond-Wedding-Rings.htm

I will have a few different of these urls. I wish to redirect all the pages with /Cat/ to a php file which will pull the Id and display the category and products.

in my htaccess I have

RewriteRule ^Cat/([0-9]+)/(.*)\.htm category.php?cat_id=$1&title=$2 [NC,L]

I'm not getting a 404 because the cms system redirects to the homepage if the page is not found.

I'm a complete noob when it comes to htaccess and I'm basing this on some of the existing rules in the htaccess which do something similar. I don't really need the title part it's really just the ID.

如果您需要的是ID,则可以使用

RewriteRule ^Cat/([0-9]+)/(.*) category.php?cat_id=$1

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