I have 2 pages in selecting data from mysql. First page - readmore.php, to get posts with url
from table posts. Second page - categories.php to get data with caturl
from table categories.
readmore.php in .htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ readmore.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ readmore.php?url=$1
categories.php in .htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ categories.php?caturl=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ categories.php?caturl=$1
My problem located when get caturl htaccess redirects me to readmore.php but I want redirect to categories.php
You are redirecting *.html to a new url readmore.php?url=*
therefor the url changes. Since the url is now readmore.php?url=*
the second set of rules won't fire (there is no longer a pattern that matches *.html).
Therefor categories will never be loaded. You will need to add a parameter in your url to distinguish the different types.
So make sure all your articles (or categories) have a common part in the url to indicate it is an page of that type.
Example:
RewriteRule ^article_([a-zA-Z0-9-/]+).html$ readmore.php?url=$1
RewriteRule ^cat_([a-zA-Z0-9-/]+).html$ categories.php?caturl=$1
So an article that was called article_firstpost.html
would link to readmore.php?url=firstpost
and cat_cars.html
would link to categories.php?caturl=cars
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.