Jump to content

A new question regarding multiple pages links?


man5

Recommended Posts

I have question regarding the setup of url for multiple pages.

 

For eg. How does one have a setup like this?

http://www.groupon.ca/deals/gatineau_en/Antirouille-Metropolitain/35853918

The setup I have is like this.

//Page 1 with posts shown in a specific catagory. 
www.mysite.ca/posts_cat.php?catagoryId=1

//Page 2 with a single post shown. 
www.mysite.ca/posts.php?title=this is my  post

As you can see, my url setup is quite different than Groupon's.  I am not sure if it's the correct way to do it; but it does work. The reason I have two different pages for posts are because I have two different css designs.

 

I suppose my question is, is my method ok? And how do I make it so it looks like Groupon's way?

 

 

Link to comment
Share on other sites

Alright so I am trying to modify the url with mod_rewrite in .htaccess.

 

Here is an example. Tell me if it's wrong.

localhost/demo/post.php?title=my post title here

RewriteRule ^post/([^/\.]+)/?$ post.php?title=$1 [L]

If it's correct, it doesn't seem to work.

Link to comment
Share on other sites

sorry for the late reply. I tried to figure this out on my own, so far so luck.

 

The urls I have are actually directory based. Like this.

<a href="posts.php?title=my post title here">Post one</a>

Can you please show me the rewrite code that outputs the above to what you mentioned?

 

And here is my .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

Thanks.

Edited by man5
Link to comment
Share on other sites

Can you please show me the rewrite code that outputs the above to what you mentioned?

That's not what mod_rewrite is for. You need to update your web pages yourself to output your friendly URL so the HTML source code received by the browser actually reads as

<a href="/demo/post/my post title here">my post title here</a>
mod_rewrite will then translate that back to your un-friendly url of

/demo/posts.php?title=my+post+title+here
If you don't update your code to output the friendly URLs in the first place, the the whole mod_rewrite setup is mostly pointless. Edited by kicken
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.