81
stelian
Re: Rewriting module URLs
  • 2006/5/12 20:55

  • stelian

  • Just popping in

  • Posts: 87

  • Since: 2005/12/17


Quote:

disky wrote:
Then on every relevant pagetemplate i took the title of a webpage and added it to the URL.

So that:
http://www.xray-mag.com/article/159
Turns into
http://www.xray-mag.com/article/159/Ferry_sinks_in_Red_Sea_
Because the headline is 'Ferry sinks in red sea'


Yes disky, how have you done this? I'm tring to do this for about 2 months :( and I didn't made it.

Thanks in advance.

82
disky
Re: Rewriting module URLs
  • 2006/5/12 22:15

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


Hi Stelian

I added the following lines to the .htaccess file in the root of my site:

RewriteEngine On
RewriteBase /
RewriteRule ^article/([0-9]+)$ /modules/fsArticle/index.php?articleid=$1 [L]
RewriteRule ^article/([0-9]+)/.*$ /modules/fsArticle/index.php?articleid=$1 [L]


In the definition of your virtual_host in your apache config you need to set:
AllowOverride All
also

Hope this help, if not just ask :)

p.s. the apache error logs are a good place to look for hints.

83
Cuidiu
Re: Rewriting module URLs
  • 2006/5/12 22:21

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Sorry... posted too soon. Answered below.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

84
disky
Re: Rewriting module URLs
  • 2006/5/12 22:23

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


Quote:

Here's what's working:
directory - domain.com/faqs/
category - domain.com/faqs/category/1.html
individual faq - domain.com/faqs/1

But I would like them to be the pagename and category name.
Can someone please help? Can someone point out what I'm doing wrong?


I am not sure i understand what you want.

Do you want to be able to have a URL like:

domain.com/faqs/Mod_rewrite_faq.html

The only way i know (and i am stilla mod_rewrite newbie) would be to have a line in the .htaccess file like this:

WriteRule ^faqs/Mod_rewrite_faq.html$ /modules/smartfaq/faq.php?faqid=117 [L]

if the id for that FAQ is 117

So you have 1 WriteRule per page, but there might be a better way to do this, but i don't know for sure.
It would not wonder me if it would be possible to do it via a MySQL database or something like that, but it is pure speculation.

Hope this helps, else just ask :)

85
Cuidiu
Re: Rewriting module URLs
  • 2006/5/12 22:36

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Hi disky,
Actually, I just wanted the page titles just as you do for articles or news. Such as:
http://www.xray-mag.com/article/159/Ferry_sinks_in_Red_Sea_
I assumed faqs could be done the same such as - domain.com/faqs/1/question_title_here.html or
domain.com/faqs/1/question_title_here or domain.com/faqs/category/1/category_title_here

However, if it is not possible to rewrite FAQs this way, I can stay with what I've got. But for my news/articles pages, I am not sure how to get the page titles as you have done because I did not understand the step:
Quote:
Then on every relevant pagetemplate i took the title of a webpage and added it to the URL.
Can you help me by telling me where I can change page templates? How would I add a page title to an url? Would it be in the module templates and where in the template? I mean, is there a common line to look for to change?

Thanks.

Quote:
disky wrote:
I am not sure i understand what you want.

Do you want to be able to have a URL like:

domain.com/faqs/Mod_rewrite_faq.html

The only way i know (and i am stilla mod_rewrite newbie) would be to have a line in the .htaccess file like this:

WriteRule ^faqs/Mod_rewrite_faq.html$ /modules/smartfaq/faq.php?faqid=117 [L]

if the id for that FAQ is 117

So you have 1 WriteRule per page, but there might be a better way to do this, but i don't know for sure.
It would not wonder me if it would be possible to do it via a MySQL database or something like that, but it is pure speculation.

Hope this helps, else just ask :)
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

86
stelian
Re: Rewriting module URLs
  • 2006/5/12 22:51

  • stelian

  • Just popping in

  • Posts: 87

  • Since: 2005/12/17


I think we have to add a line in .htaccess for every title in URL we would like to have.
Is it wright disky?

What do I have to do if I want to display the category in the url?
from
/modules/catads/adslist.php?cat_id=1
/modules/catads/adslist.php?cat_id=2
etc
...
to
/modules/catads/computers
/modules/catads/automobiles
etc
...


Thanks for your help.
Regards.

87
disky
Re: Rewriting module URLs
  • 2006/5/12 23:04

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


Cuidio:

You need a .htaccess line like:
RewriteRule ^article/([0-9]+)/.*$ /modules/fsArticle/index.php?articleid=$1 [L]

With this RwwriteRule, you can have URL's like:

domain.com/article/117/bla_bla_bla_bla

It simply ignores everything after /117/

p.s. You need to adjust it to the module you use.

88
disky
Re: Rewriting module URLs
  • 2006/5/12 23:07

  • disky

  • Just popping in

  • Posts: 90

  • Since: 2003/10/31


Hi Stelian

I think you need something like:


WriteRule ^faqs/Mod_rewrite_faq.html$

WriteRule ^/modules/catads/computers$ /modules/catads/adslist.php?cat_id=1 [L]

WriteRule ^/modules/catads/automobiles$ /modules/catads/adslist.php?cat_id=2 [L]

Hope it works

p.s. Both of you i'll be back in 8-10 hours, i need sleep. Here in denmark it is 01:22 am i have been playing to much with my server :) See ya

89
Cuidiu
Re: Rewriting module URLs
  • 2006/5/12 23:35

  • Cuidiu

  • Quite a regular

  • Posts: 358

  • Since: 2006/4/23


Thanks. Are you saying that with the page titles anything after domain.com/dir/117/ I can fill in - but that would be manually if I'm setting the URL somewhere in the menu or something, correct? Otherwise, it will be just domain.com/dir/117/ normally. I fear this has potential for duplicate URLs in search engines causing penalites if by chance only the dir/117/ is picked up somehow. Also the other URLs still work too - the index.php?articleid=# URLs. I would not want any URL to be active except the URL that I've got set in menus on the pages. I assume there is no way around this.

Also, on the page I am getting the _MD_SF_REQUESTEDANDANSWERED (1 _MD_SF_READS) in the page. It should say: Requested and Answered by Admin on 02-May-2006 09:54 (6 reads). I have tried to figure out where in the templates to change but have not found it. All links within the module are not changing and I don't know how to do this either. Can I hire you? This is just too complicated for me. You made it look so easy in your posts!

Quote:

disky wrote:
Cuidio:

You need a .htaccess line like:
RewriteRule ^article/([0-9]+)/.*$ /modules/fsArticle/index.php?articleid=$1 [L]

With this RwwriteRule, you can have URL's like:

domain.com/article/117/bla_bla_bla_bla

It simply ignores everything after /117/

p.s. You need to adjust it to the module you use.
[size=x-small]Working sites:
XOOPS 2.0.16 PHP 5.2.2, MySQL 5.0.24a-standard-log, Apache/2.0.54 (Unix)
XOOPS 2.2.4, PHP 4.3.10, MySQL 3.23.58, Apache/1.3.33 (Unix)[/size]

90
stelian
Re: Rewriting module URLs
  • 2006/5/13 8:26

  • stelian

  • Just popping in

  • Posts: 87

  • Since: 2005/12/17


It is not working for me. Anyway, I would like to continue the work to this hack.

Disky, thank you for your support.

Login

Who's Online

387 user(s) are online (255 user(s) are browsing Support Forums)


Members: 0


Guests: 387


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits