How can I point my SEF Url to different pages?

Asked by SkinnerG

That's it. I wanna know if I can point the SEF rewrote articles to different pages not only the one specified on the .htaccess. For example, a rule on .htaccess that can get the $phpns [script_link] on where news are being displayed at the time.

I have on the same page news pointing to different pages by category. Example:
The box containing the Relevant News points to RELEVANT.PHP;
The Internet news box on the home page points to INTERNET.PHP;
The Hardware news box on the home page points to HARDWARE.PHP;

OK, enough. U got it, I hope.
So, how can I do it? How can I turn my articles to SEF pointing to different pages.

Question information

Language:
English Edit question
Status:
Answered
For:
phpns Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
alecwh (alecwh) said :
#1

The $phpns['sef'] pre-include variable will let you set a value like "hardware":

$phpns['sef'] = "hardware/";

That will prefix all of the SEF urls with "hardware/", like this:

http://example.org/hardware/Why-I-love-my-laptop

And you can modify your .htaccess to handle that accordingly. Good luck!

Revision history for this message
SkinnerG (guitosk) said :
#2

Thanx, Alecwh.

Not what I was expecting as an answer cos I already thought about this way. Just wanted to know if there is was any way to direct to php pages instead of creating new directories.
Apparently it is impossible. Anyway... now I have the error "stop!" and some message about the ID that I cant paste here now cos my webserver is down LOL.
What's the meaning of that error related to SEF pages? What do I got to do to fix it out?

Hug

Revision history for this message
alecwh (alecwh) said :
#3

SkinnerG,

You don't need to create any directories. You can use this technique I
described, and reroute the request to the appropriate PHP page.

For example, with .htaccess, you could route this:

http://example.org/hardware/Article-title-here

to the script:

http://example.org/hardware.php. You can also set it up so anything
between http://example.org/ and /Article-title-here can be the name of
the PHP script in question.

The URL looks like you would be creating new directories, but it is an
illusion that .htaccess provides. :)

Revision history for this message
SkinnerG (guitosk) said :
#4

Man, sorry to keep on bothering but it is not working. Make it simple for me... how should my .htaccess look like? And how should my include look like?
Ty

Revision history for this message
alecwh (alecwh) said :
#5

SkinnerG,

While I would like to make it simple for you, I cannot. I added that
feature to $phpns['sef'] because I was aware that you could achieve
something like what you want. I don't know very much about mod_rewrite,
so, do some research.

>From my understanding, there is something you can do with variables,
such as $1 and $2, which would represent different areas of the URL
given, and you can redirect to a script with those variables. Check
Phpns's recommended .htaccess (provided in the admin section under "SEF
URLs" in Preferences), and I'm sure that will give you an idea.

Your PHP script will look like this:

<?php
$phpns["sef"] = 'hardware/'
include(...)
?>

and then use a 'software/', etc. or whatever for your other includes.

Good luck.

Can you help with this problem?

Provide an answer of your own, or ask SkinnerG for more information if necessary.

To post a message you must log in.