Pretty URLS running .... but... one question!
Re: Pretty URLS running .... but... one question!
Is there no way to make it www.domain.com/news/01/02/my-title-in-news, since I believe search engine takes the actual page url as more weight than the title being as if it's a directory
Re: Pretty URLS running .... but... one question!
I don't believe that about the order of your words in your URL bearing any weight on SE rankings, but yes, you can do that.
Take a look at what fritzfs and give it a try
For those who are lazy here it is (not the full solution, only the changes needed to be made from the solution fritzfs posted. Do not blame me for any typos I make. You also don't have to do the trailing slash stuff if you don't want to.
Edit file modules/News/action.default.php at about line 312 (it was 313 for me) and replace with this:
Edit .htaccess file and set like this:
This exercise was great though as it's given me a little more insight into rewriterules and maybe one step closer to creating clean, friendly tag URLs for the tag module 
Take a look at what fritzfs and give it a try

For those who are lazy here it is (not the full solution, only the changes needed to be made from the solution fritzfs posted. Do not blame me for any typos I make. You also don't have to do the trailing slash stuff if you don't want to.
Edit file modules/News/action.default.php at about line 312 (it was 313 for me) and replace with this:
Code: Select all
$prettyurl = 'news/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid).'/'.str_replace(' ', '-', $onerow->title);
Code: Select all
# News
RewriteRule ^news/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [L]

Re: Pretty URLS running .... but... one question!
Yes, you can use my posted code and change the order of variables as nivekiam instructed.
Please notify me if you have any trouble getting it up & running.
Please notify me if you have any trouble getting it up & running.
Re: Pretty URLS running .... but... one question!
Hi !
Thanks for all these tips
But what about the RSS feed ? How can i set the new url into ? We need a Smarty tag (the link with keywords) which doesn't exist !
Good night.
Lio.
Thanks for all these tips

But what about the RSS feed ? How can i set the new url into ? We need a Smarty tag (the link with keywords) which doesn't exist !
Good night.
Lio.
Re: Pretty URLS running .... but... one question!
Great tip.
It worked great for me, except I added in the strtolower function to make sure the clean URL was in all lower case letters. When taking the news title, more than likely there will be some capital letters for when you Write Headlines Like This. It's better practice to not include capital letters in the URL and it will match the rest of your site URL structure by default.
I haven't had much time to dig further for tonight, but is there a way to display clean URLs for category listings? And a step further would be to include the option to have clean URLs for the pagination links too.
It worked great for me, except I added in the strtolower function to make sure the clean URL was in all lower case letters. When taking the news title, more than likely there will be some capital letters for when you Write Headlines Like This. It's better practice to not include capital letters in the URL and it will match the rest of your site URL structure by default.
Code: Select all
$prettyurl = 'news/'.str_replace(' ', '-', strtolower($onerow->title)).'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);
Re: Pretty URLS running .... but... one question!
The page URL's work great. They are now more SEO friendly.
However, I am having trouble with the NEWS.
The News URL looks nice when I scroll over it:
http://www.example.com/news/Smile-South ... stry/2/15/
But, when I click on it, I get a 500 Internal Server Error.
If I change the action.default.php in the modules/news/ folder to...
$prettyurl = ''.str_replace(' ', '-', $onerow->title).'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);
... it will go to the url without the news folder (http://www.example.com/Smile-South-Flor ... stry/2/15/), but it will display the home page.
So, I think it has something to do with the News Tag in my .htaccess file:
# News
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]
Any insights?
Thanks,
Alex
However, I am having trouble with the NEWS.
The News URL looks nice when I scroll over it:
http://www.example.com/news/Smile-South ... stry/2/15/
But, when I click on it, I get a 500 Internal Server Error.
If I change the action.default.php in the modules/news/ folder to...
$prettyurl = ''.str_replace(' ', '-', $onerow->title).'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);
... it will go to the url without the news folder (http://www.example.com/Smile-South-Flor ... stry/2/15/), but it will display the home page.
So, I think it has something to do with the News Tag in my .htaccess file:
# News
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]
Any insights?
Thanks,
Alex
Last edited by Anonymous on Fri Feb 22, 2008 7:06 pm, edited 1 time in total.
Re: Pretty URLS running .... but... one question!
You didn't follow the instructions 
Since you went off path and removed the /news from the URL, you need to remove that from the rewrite rule:
I don't know if that solve the problem, but that's where I'd start. If that doesn't fix it, please post all your rewrite rules and any other changes you made and put them in a code block (click the little # button when creating your post) so your code doesn't wrap the screen and we can see exactly what you have. Notice, how the rewrite rule I posted doesn't wrap the line.

Since you went off path and removed the /news from the URL, you need to remove that from the rewrite rule:
Code: Select all
# News
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]
Re: Pretty URLS running .... but... one question!
Wow!!! You are awesome! Thank you so much.
Here is my .htaccess:
How do I add the news element? I tried before, but got an error.
In action.default.php, I put
I put in the .htaccess...
BUT, I got a 500 Internal Server Error.
The suggestion you made worked, but I could not apply it to the situation when I add the news directory.
What do you think?
Thanks, again!
Alex
Here is my .htaccess:
Code: Select all
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# News
RewriteRule ^([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3
[L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
In action.default.php, I put
Code: Select all
$prettyurl = 'news/'.str_replace(' ', '-', $onerow->title).'/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);
Code: Select all
# News
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3
[L]
BUT, I got a 500 Internal Server Error.
The suggestion you made worked, but I could not apply it to the situation when I add the news directory.
What do you think?
Thanks, again!
Alex
Re: Pretty URLS running .... but... one question!
Well I'm not rewrite expert, far from it, but it's really easy to make typos and generate 500 server errors...
The only difference I can see in what you posted versus what I posted is you don't have [L] on the same line as your RewriteRule
(scroll all the way to the right)
Yours
(scroll all the way to the right)
What I posted
I really don't know if that will make a difference or not, but it's worth a try. I can't see anything else that's different.
The only difference I can see in what you posted versus what I posted is you don't have [L] on the same line as your RewriteRule
(scroll all the way to the right)
Yours
Code: Select all
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3
[L]
(scroll all the way to the right)
What I posted
Code: Select all
RewriteRule ^news/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$2&cntnt01returnid=$3 [L]
Re: Pretty URLS running .... but... one question!
Just implementing this pretty url scheme for news and noticed that if news titles have a "." in them, it can break the link.
Anybody else notice that?
Tom
Anybody else notice that?
Tom
Re: Pretty URLS running .... but... one question!
I've tried the pretty url modification as Nivekiam has given instruction for but I have characters in the title of my news articles with special characters such as £, $, !. These special characters are showing in the url so is there a way how to strip out any characters which are not in the alphabet so you can have a url like /news/hello-world instead of /news/hello-world!
Thanks
Thanks
Re: Pretty URLS running .... but... one question!
This is the reason this hasn't been implemented natively in the News module. Calguy1000 has posted about this someplace, it would be a lot of work.
I see 3 choices, do not use special characters, do not use this mod/hack, modify the news module to work with Pretty URLs, disallowing special characters in the titles or re-working it so it has an additional property of "alias".
I see 3 choices, do not use special characters, do not use this mod/hack, modify the news module to work with Pretty URLs, disallowing special characters in the titles or re-working it so it has an additional property of "alias".
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Pretty URLS running .... but... one question!
The alias problem is a very common one. You cannot re-use a 'Name' that may contain quotes, or funky non alphanumeric characters as URL.
The same applies with custom fields. if you put special characters (or even spaces) into your custom field names, then you may have problems with templating, and a whole host of other issues.
To properly fix these problems, and to put some text that resembles the article name on the URL will require a significant amount of effort (particularly testing, that's always a pain in the ass) by somebody that is familiar with PHP, and familiar with the module api.
Hence, the news module doesn't support these pretty urls. It's on my todo list, but paying projects and CMS 2.0 are higher on my priority list at the moment.
The same applies with custom fields. if you put special characters (or even spaces) into your custom field names, then you may have problems with templating, and a whole host of other issues.
To properly fix these problems, and to put some text that resembles the article name on the URL will require a significant amount of effort (particularly testing, that's always a pain in the ass) by somebody that is familiar with PHP, and familiar with the module api.
Hence, the news module doesn't support these pretty urls. It's on my todo list, but paying projects and CMS 2.0 are higher on my priority list at the moment.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- New Member
- Posts: 3
- Joined: Fri Mar 14, 2008 9:15 pm
Re: Pretty URLS running .... but... one question!
Action.default.php
If I go to this unpretty url you'll see the title header.
http://www.spottheweasel.com/index.php? ... eturnid=26
but when I try the prettied up url
http://www.spottheweasel.com/news/10/26 ... -Elements/
I just get the images titles, and when I go back into editing they show up. So I dunno what the solution is.
Was used with$prettyurl = 'news/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid).'/'.str_replace(' ', '-', $onerow->title);
for pretty news urls and wile as a side effect, images refuse to display in news now.# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# News
RewriteRule ^news/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
If I go to this unpretty url you'll see the title header.
http://www.spottheweasel.com/index.php? ... eturnid=26
but when I try the prettied up url
http://www.spottheweasel.com/news/10/26 ... -Elements/
I just get the images titles, and when I go back into editing they show up. So I dunno what the solution is.
Re: Pretty URLS running .... but... one question!
It's the way you are referring to that image. Don't use "uploads/images/EE-large.jpg" Either use "http://www.spottheweasel.com/uploads/im ... -large.jpg" or "/uploads/images/EE-large.jpg"
On this page, http://www.spottheweasel.com/news/10/26 ... -Elements/, the browser is looking for the image at:
http://www.spottheweasel.com/news/10/26 ... -large.jpg
Personally I always refer to images and pages on my site using absolute URLs, "http://www.spottheweasel.com/uploads/im ... -large.jpg". A lot of people don't like doing that because that can create additional work depending on how you have your development environment setup. But I use absolute URLs for my own reasons.
On this page, http://www.spottheweasel.com/news/10/26 ... -Elements/, the browser is looking for the image at:
http://www.spottheweasel.com/news/10/26 ... -large.jpg
Personally I always refer to images and pages on my site using absolute URLs, "http://www.spottheweasel.com/uploads/im ... -large.jpg". A lot of people don't like doing that because that can create additional work depending on how you have your development environment setup. But I use absolute URLs for my own reasons.