Jump to content

Mod Rewrite - Change url structure.


Ninjakreborn

Recommended Posts

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]

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.