GetSimple Support Forum

Full Version: .html extension in page's url
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Howdy
I've stumbled upon a problem after modifying an old, static website.
After converting /*.html pages to GS, old links ceased to work.
There's no problem with rewriting them using mod_rewrite.
But I'd like to get the possibility to do it from within GS admin panel, just by adding .html in the page's url field.

clean_url() function inside basic.php stripes unnecessary chars from url, and after modifying it I'm able to save the page with fake .html extension.
But that's not all what I needed to change, as I get 404error while visiting such page.
Could anyone point me to the right function where I could tweak the code to achieve the goal, or maybe there's another, supersimple solution ?
(2014-01-13, 06:41:53)yojoe Wrote: [ -> ]Could anyone point me to the right function where I could tweak the code to achieve the goal, or maybe there's another, supersimple solution ?

Personally, I would search/replace the site content and get rid of the old .html extensions on static links. I think that would be the most reliable way and the least likely to cause problems in the future.

For a quick-and-dirty solution, could you add to the base .htaccess:
Code:
AddType application/x-httpd-php .html
?
(2014-01-13, 19:13:48)hameau Wrote: [ -> ]Personally, I would search/replace the site content and get rid of the old .html extensions on static links. I think that would be the most reliable way and the least likely to cause problems in the future.
Well, no. That's not the case. There are other methods to point to new content, but the case is dead simple: let GS handle extension in url through page's options. html extension is a default one, but making it work, there should no problem with using any string after dot.

(2014-01-13, 19:13:48)hameau Wrote: [ -> ]For a quick-and-dirty solution, could you add to the base .htaccess:
Code:
AddType application/x-httpd-php .html
?
This rule forces php parser to handle existing .html files. It just can't work.
It would be great to know if it's possible just by changing 1-2 basic functions. I'm not fond of deep changes in GS core.

edit: there's a "Link Juice" plugin, but redirecting 404s to index isn't still the right solution :\
This may sound stupid but have you tried anything from here?
In that case, I don't really understand you problem, however:
(2014-01-13, 19:39:31)yojoe Wrote: [ -> ]
(2014-01-13, 19:13:48)hameau Wrote: [ -> ]Personally, I would search/replace the site content and get rid of the old .html extensions on static links. I think that would be the most reliable way and the least likely to cause problems in the future.
Well, no. That's not the case. There are other methods to point to new content, but the case is dead simple: let GS handle extension in url through page's options. html extension is a default one, but making it work, there should no problem with using any string after dot.

Modifying a standard system (GS, in this case) to overcome a deficiency elsewhere (your old content) is rarely a good engineering solution. StackOverflow is full of similar questions with suggestions for .htaccess rewrite rules.
Use a custom rewrite rule and a permalink structure.
I am fairly certain this exact scenario was covered in forums somewhere.

In fact the bottom of the page that everyone posted shows exactly how its done.
You assume all pages have .html extension. They do not.
It's a mix, where those with .html (any possible extension) should get incoming traffic instead of showing the visitor a 404, or redirecting him to /index
Custom link structure with rewrite rules won't cover that.

hameau: I don't think I'd be able to create rewrite rules with exceptions for files with and without extension. StackO. won't be helpful, as there would have to be people who are familiar with GS sourcecode. And who might be more familiar than people visiting this forum ? Wink

But GS custom link structure is a hint. I'll look at function(s) responsible for it.
If it is only some then just redirect them all to the new structure.
I don't really understand what the problem is.

redirect all (*).html to index.php?id=$1
or rewrite so it is transparent.

all can be done in htaccess.

If you want to handle it in gs only, then use the errro404 hook and map the .html to the slug and return the content.
3.3.0 makes this even easier with 2 new filters.
(2014-01-14, 01:55:26)yojoe Wrote: [ -> ]You assume all pages have .html extension. They do not.
...
Custom link structure with rewrite rules won't cover that.

Of course it can – that's what rewrite conditions are for.

(2014-01-14, 01:55:26)yojoe Wrote: [ -> ]I don't think I'd be able to create rewrite rules with exceptions for files with and without extension.

Well, it's certainly possible. If you mean, you don't have the experience to create the rules, I understand: neither do I. But I'm sure Google knows how. Sometimes it's necessary to learn about stuff that isn't an every-day problem ... In the 24 hours that you've been asking for help here, you probably could have found everything you need.

If I have still misunderstood, then I apologise for being abrupt.
There is already a rewrite rule exception for files and directories in our htaccess.