Jump to content

[SOLVED] Clean URLs


Balmung-San

Recommended Posts

Okay, so I read the tutorial, but I'm still not entirely sure about how to clean up URLs.

How's about I make a sample case.

Let's say I have the following pages:
http://www.mydomain.com/download.php
http://www.mydomain.com/index.php
http://www.mydomain.com/news.php
http://www.mydomain.com/article.php

Now, let's say both download.php, article.php, and news.php all accept article titles as a passed variable as such:

http://www.mydomain.com/article.php?title=Some-Article

How would I make it so that http://www.mydomain.com/article/Some-Article points to the same page, without using mod_rewrite? My webhost does not allow mod_rewrite.
Link to comment
Share on other sites

[quote author=fooDigi link=topic=120940.msg496617#msg496617 date=1167887647]
looks as though phpfreaks has a tutorial regarding this. forgive me, i have not read it all. hope this works for you.

[url=http://www.phpfreaks.com/tutorials/149/0.php]http://www.phpfreaks.com/tutorials/149/0.php[/url]
[/quote]

I had already read the article and I was still confused at the end. Mostly, where would I put the parsing include? How does it know not to look in a directory named http://www.mydomain.com/article/Some-Article?
Link to comment
Share on other sites

Ignore my entire post.. I missed the part where you mentioned your host doesn't allow mod_rewrite :P


[s]What I use is Apache's Mod Rewrite.

Usually used in a .htaccess file and looks similar to:[/s]
[code]
RewriteEngine On

RewriteRule ^/article/([0-9A-z]+)$ article.php?title=$1

[/code]
[s]
:) I also add hyphens into the title and then strip them out if I need to display the proper title or when I need to query my database for the content.

The .htaccess file is added to the directory of your website.

The previous code I used can be found here: http://www.tingram.ca/blog/Apache-mod_rewrite though it uses the ID of the post and not the title like it does now.[/s]

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.