Ninjakreborn Posted December 13, 2010 Share Posted December 13, 2010 Url: http://www.nrmkids.com Right now all the URLS do their own thing. Most of the time the structure is very simple. www.nrmkids.com/pagename. That is fine. For the products listing it's www.nrmkids.com/pagename/category Then for the product details view it's www.nrmkids.com/pagename/category/productid Those are all great. There is one problem. If you go to the site and click on "Kids Wall Art" or "Boys Wall Art" it takes them to the right page www.nrmkids.com/pagename/categorynumber Which is great. Well that works, when they also click on a product that is great. However, I need for it to be different for the pagination> If you click on the next page in Pagination (for example with Bosy Wall Art) it does this. http://www.nrmkidswallart.com/index.php?page=2&c=1 What I want to do is change that to still have boyswallart in the name. I want to do the same for kidswallart, and girlswallart. However that conflicts with the other URLS (like for showing product details). Does anyone have any advice on this. HTAccess File RewriteEngine on php_value upload_max_filesize "10M" php_value post_max_size "10M" php_value memory_limit "256M" RewriteCond %{HTTP_HOST} ^nrmkidswallart.net$ [OR] RewriteCond %{HTTP_HOST} ^www.nrmkidswallart.net$ RewriteRule ^(.*)$ "http\:\/\/www\.nrmkidswallart\.com\/$1" [R=301,L] RewriteCond %{HTTP_HOST} ^nrmkids.com$ [OR] RewriteCond %{HTTP_HOST} ^www.nrmkids.com$ RewriteRule ^(.*)$ "http\:\/\/www\.nrmkidswallart\.com\/$1" [R=301,L] RewriteBase / RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2&p=$3 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2&p=$3 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2&p=$3&ct=$4 RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&c=$2&p=$3&ct=$4 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Quote Link to comment https://forums.phpfreaks.com/topic/221528-mod-rewrite-change-url-structure/ Share on other sites More sharing options...
strago Posted January 22, 2011 Share Posted January 22, 2011 Any time a URL conflicts with the other URLS, you have to add something unique to the URL, like an extra fake direcory, like RewriteRule ^shop/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2 index.php?page=2&c=1 being domaIn.com/shop/2/1 or adding a fake extension. RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\.html$ index.php?page=$1&c=$2 being domaIn.com/2/1.html or RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\.html$ index.php?page=$2&c=$3 and you edit the script to make the first directory in the URL be a variable like boyswallart. And the extention wt the end of the URL will keep them from having conflicts, for nrmkidswallart.com/boyswallart/2/1.html Quote Link to comment https://forums.phpfreaks.com/topic/221528-mod-rewrite-change-url-structure/#findComment-1163465 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.