redirect wordpress calls to a page - redirect

I'm not really sure what is the best way to do this. Say you have set up a page like so:
www.myblog.com/page1
Is it possible to, specify that the request to any of the subpages under page1 be redirected to a single page? Say if I had page1.php as one of my pages, any URL that is prefixed with:
www.myblog.com/page1/...
wordpress would use that file to generate the page.
Basically, I have some custom content that I want fetched with php, and it depends on which subpage is being loaded. The format of the custom content is always the same, only the 'arguments' differ. Is there a way to do this within Wordpress? And if not, where should I should I start looking to implement this?
Thanks

try modifying .htaccess file and rewriting url so all requests for /page1/page2 will be rewrite to /page1=?page=page2 or something like that

Related

TYPO3 v9 pages accessible through URL like /page/<pageId>/

How can I do with the new Routing API to make pages accessible through something like https://example.com/page/{idOfThePage}? Normal slug behavior with page title still needs to work.
Thanks
The easiest solution would be to just adapt the page slugs in the page properties. For many pages you can do that in the DB (field pages.slug).
If you want new pages and the slug autogeneration in the backend to follow that, too you can overwrite EXT:cores pages TCA in your TCA/Overrides/pages.php (docs TCA type slug).
I suggest (not tested):
$GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['fields'] = ['uid'];
$GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['prefixParentPageSlug'] = false;
I have no idea how to get the base /page in there. You could set your site's base path to /page in site config maybe? Or you might need a generatorOptions[postModifier].
Notice:
A routeEnhancer might come to mind first for rewriting URLs. And yes, for other simple parameters a SimpleEnhancer is able to do that - yet for the base path/pageUid it is not.

OctoberCMS Get URL to CMS page

In October CMS, you can easily create a link to a CMS page in a Twig template with reverse routing. For example:
Go to help page
will link to the CMS page with the filename help.htm, substituting the URL with the URL defined in that page.
However, for the life of me, I can't figure out how to get the URL to a CMS page in a component to create a redirect to it.
I tried:
return Redirect::to('help');
which simply redirects to /help URL, which isn't the correct URL, so I get a 404.
I also tried:
return Redirect::to(\Url::route('help'));
However this produces an error because it is not registered as a route.
The reason I can't just hard-code the URL is because I am using the Translate plugin, which means that I can have a different URL depending on the language. So for example, in English it would be /en/help, but in Spanish it would be /es/ayuda. Putting:
{{ 'help'|page }}
in my Twig files will automatically get the correct URL based on the current language.
Is this possible to do in a component or controller?
Within your component you can use controller's pageUrl method.
$this->controller->pageUrl(<file_name>, <params>);
according to your need, this should do the trick
return Redirect::to($this->controller->pageUrl('help'));
if any doubt please comment.

Rewrite .html files in Netlify

I am trying to rewrite patterns like /abc.html to /search?xyz=abc. 'abc' can be anything.
I've gone through the documentation at https://www.netlify.com/docs/redirects/
Here's what I have now in my _redirect file, but it doesn't seem to work. Kindly help.
/*.html /search?xyz=:splat 200
Disclaimer: I work for netlify
Our redirects functionality does not work to do rewrites like that. Placeholders like slugs (/blog/:year/:month/:day/:title) and stars (/assets/*) are only matched as full path components - that is, the thing between slashes in a URL or "everything after this / including files in subdirectories".
It's not an uncommon feature request, but our system doesn't work like that right now.
Some ways you can achieve similar goals:
usually you aren't intending to redirect existing paths. This portion of the docs demonstrates that a standard redirect (/articles/* /search?xyz=:splat 301) will redirect all requests for missing content - be that /articles/1 or /articles/deep/link/that/was/tpyoed.html - to /search with a xyz parameter of the pathname . This doesn't do exactly what you asked - but it is probably the closest thing and you can hopefully handle the paths appropriately in your /search page. In case you have any contents under /articles, that will still be served, and not redirected, since you didn't put a ! on the redirect to force it.
if you have a single page app that does its own routing and use a history pushstate redirect you could make the router do the right thing for your content since usually there is only one .html page on your site and any other paths would be redirected to it (where the router takes over with whatever smarts you give it)

How to manipulate the meta area of the HTML dom with Scala-JS for a single page application

General Scala-JS page building advice needed. Most of the examples seem to be of the pattern where the main into which your single page application will go is between the tags in a landing page html file. How do you handle the need to insert something in the meta area of the dom? Do I need to render my landing page dynamically from the server to accomplish this? My specific need is to inject a script tag into the meta area of an already defined static html page. I'm using scalajs-react.
Generally you will want a server-rendered "root page" for the SPA. This allows you to dynamically compute proper cache busting file names for your script and stylesheet tags and to easily manage the cache expiration of the root page. Also, for proper html5 push state support you'll want to serve that page at every URL, which is easily done with a server side route.

handle subpages inside facebook app (with one single tab)

My goal is that have a fb page app (only in one tab) and use it with linkable subpages inside it.
For example:
If I click on subpage link there would be a http or ajax request inside the iframe. Thats fine, i can do that.
BUT
in the solution I also want to implement these two features:
1.:
I want that page to be accessible directly from an url like:
http://facebook.com/pagename/app..blabla/subpage1
or
http://facebook.com/pagename/app..blabla&sk=535&subpage=1
or
http://facebook.com/pagename/app..blabla#subpage1
2.:
On subpage link click inside iframe I want the browser url to turn into something like mentioned in the 1. point. (even when using ajax - probably with a hash tag)
Is it possible?
If you look at the page tab tutorial http://developers.facebook.com/docs/appsonfacebook/pagetabs/ at the bottom of the page they describe how you can create the 'subpage' idea using the app_data parameter. So your links will look like http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here
For your second question, in the links on the page you would specify target="_top" in any links you have with the href being: http://www.facebook.com/YourPage?v=app_1234567890&app_data=subpage1. This will cause the entire page tab to load through Facebook and you'll get the signed_request and your app_data parameters.
You probably don't want your ajax to load through facebook, because you'll get the Facebook page back instead of json or whatever you are trying to load. Instead you'll just make ajax calls to your server and pass the parameters you need to, like app_data or whatever you want.