Posts: 1,204
Threads: 30
Joined: Jun 2010
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 ?
Addons: blue business theme, Online Visitors, Notepad
Posts: 423
Threads: 15
Joined: Mar 2011
(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
?
--
Nick.
Posts: 1,204
Threads: 30
Joined: Jun 2010
2014-01-13, 19:39:31
(This post was last modified: 2014-01-13, 20:54:47 by yojoe.)
(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 :\
Addons: blue business theme, Online Visitors, Notepad
Posts: 52
Threads: 2
Joined: May 2013
This may sound stupid but have you tried anything from here?
Posts: 423
Threads: 15
Joined: Mar 2011
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.
--
Nick.
Posts: 6,266
Threads: 181
Joined: Sep 2011
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.
Posts: 1,204
Threads: 30
Joined: Jun 2010
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 ?
But GS custom link structure is a hint. I'll look at function(s) responsible for it.
Addons: blue business theme, Online Visitors, Notepad
Posts: 6,266
Threads: 181
Joined: Sep 2011
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.
Posts: 423
Threads: 15
Joined: Mar 2011
(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.
--
Nick.
Posts: 6,266
Threads: 181
Joined: Sep 2011
There is already a rewrite rule exception for files and directories in our htaccess.
|