I am upgrading my website from Yii 1.1 to Yii2. In the older site using Yii 1.1, the url can be given as
http://example.com/index.php/controller_name/action_name/queryString/123
But in Yii2 I have to change this request to
http://example.com/index.php/controller_name/action_name?queryString=123
in order to make it work, otherwise I get a 404 Not Found error.
I already know that this feature has been removed in Yii2 Github issue 6866, but since the older site heavily uses this particular feature, I would like to know if there is any workaround, without changing each individual URL in the existing website.
Thanks
You need to enable pretty urls,and the add rules accordingly.
Related
My Laravel 5 Application is installed under the Directory Name:
MyAccount
I have following Url in the application:
http://localhost:1234/laravel/MyAccount/public/allskills
This is due to below route:
Route::get("/allskills", "Skills\SkillsController#index");
I am trying to change my Url to below:
http://localhost:1234/allskills
Question: Am I missing any setting in the above routing code ?
I'd recommend using laravel homestead. There are plenty of tutorials online (including screencasts on YouTube) that guide you through it. You can map a url like
"skills.app" to your MyAccount/public directory, so it can be accessed as
skills.app/allskills
If you want to find out more, check outt this short video series on YouTube, but of course if you don't want to go to these lengths you could use one of the answers already given.
Our current website is built using AngularJS and as a result has URLs with /#/in them such as http://www.website.com/#/termsofuse
Short-sightedly, the URL for terms or use has been hard coded into a mobile application and although this has been changed, some users still have older versions.
We're moving to a WordPress site (running on Azure) and the new URL for terms of use is http://www.website.com/termsofuse
The issue is that I want to redirect to the new URL if the old URL is used (from the app where it is hard coded in older versions) but I can't find a way to do this with the /#/ in the URL (otherwise I could use HTML/JS at the old URL to redirect).
I have tried searching for solutions on Google and here but although I'm sure someone has had this problem, I'm finding it hard to define the search terms in order to get valuable results.
I also considered posting this on WordPress stackexchange but it is not really a WordPress question, I'm assuming I'll need to use some other method.
Appreciate any ideas or advice. Thanks in advance.
So far I have learnt from responses that I probably need a JS solution and based on that I have found the below which looks similar (at least shows me how to isolate the fragment after the URL). Since my issue is very specific, and I only need to look for the specific fragment #/termsofuse could I use this code (with midifications) to look for that string and redirect based on that?
Checking URL fragment for a keyword
Sadly, this is not possible as everything after the # doesn't get sent to the server.
What many people do in this sort of situation is to use a javascript/ajax solution to load the page.
By your description, as your new web site is built on WordPress without AngularJs.
So it hardly could approach your need in a traditional way. As hashtag # is a client symbol which is never passed on serve, so IIS on Azure will not get the portion after # of the URL, also URL rewrite module won’t see it too.
So if possible to modify home page of your WordPress site, here is a workaround with using JavaScript get the portion after # of the URL and redirect to the right URL.
Here is the code snippet:
(function () {
console.log(window.location.href);
var url = window.location.href;
params = url.split('#');
console.log(params);
if(params[1]){
window.location.href = params[1];
}
})();
A couple of months ago, I built this lead dashboard (*) in pure PHP.
A key feature of my lead dashboard is that it's very flexible in its URL parsing. Parameters can be added to the end of the URL and the order or quantity really doesn't matter. See examples below.
I'm currently porting my dashboard to a Wordpress system and would like to maintain this same flexibility, but it's not really clear to me what would be a good strategy in Wordpress to implement this routing technique. Should I go for an .htaccess based solution? Should I add a filter? Should I add an action? And which filter or action would seem the most suitable?
Any suggestions on how to do this the right way?
Example URL 1 :
http://www.johnslegers.com/lead-dashboard/
Example URL 2 :
http://www.johnslegers.com/lead-dashboard/keyword:Stackoverflow
Example URL 3 :
http://www.johnslegers.com/lead-dashboard/keyword:Stackoverflow/language:English
Example URL 4 :
http://www.johnslegers.com/lead-dashboard/language:English,Dutch/keyword:Stackoverflow,problem
Example URL 5 :
http://www.johnslegers.com/lead-dashboard/value:3500/percentage:5,15,30,50,70/language:English,French,German/keyword:Stackoverflow,problem
Example URL 6 :
http://www.johnslegers.com/lead-dashboard/keyword:Stackoverflow,%20programming,%20code,%20Wordpress,%20problem/language:English/currency:US%20Dollars/percentage:5,10,20,50,85/cost:0.9,9,34,108/value:5400
EDIT :
(*) Google decided to impose an RMF policy that requires any dev to implement a long list of features of they want to use their Adwords API. Because my app uses only a few features of Adwords and thus doesn't comply with this policy, Google no longer allows me to access their API. This means that the tool no longer functions correctly and cannot be fixed unless Google decides to change their policy. Because the tool no longer functions correctly, I removed the link.
I ended up solving this issue myself.
To fix my problem, I just had to add the following action function to the functions.php file of my theme :
function simulationpage_init() {
// Remember to flush the rules once manually after you added this code!
add_rewrite_rule(
// The regex to match the incoming URL
'simulatie/.*',
// The resulting internal URL
'index.php?pagename=simulatie&data=$matches[1]',
// This is a rather specific URL, so we add it to the top of the list
'top');
flush_rewrite_rules();
}
add_action('init', 'simulationpage_init');
That achieved exactly what I wanted!
I’m a recent user of Codeigniter and am developing a simple backend CMS to manage pages.
Based on a URL (in this example I have hidden “index.php”) : mysite.com/pagename
I would like the system to detect if there is a value of “pagename” in my database, if there is, I need the system to re-route to a custom controller (eg: Pagemaker) and if there is no record called pagename, just do it’s normal thing (i.e. find a controller called pagename)
Currently I have:
$route['(:any)'] = "pagemaker/create/$1";
whereby all requests are forwarded to my custom function.
However I want to change this structure so that if the page does NOT exist in the db, the traditional codeigniter request process is followed.
Can anyone offer any advice about how to complete this? Or any advice about routing custom CMS’s in codeigniter in general?
The best solution is to upgrade to CI 2.0 because it's stable enough and it gives you plenty of useful features.
In your case, set the following route:
$route['404_override'] = 'pagemaker';
If the router doesn't know where to go it just goes to pagemaker controller. This can then check if the first uri segment exists and if not you create a custom 404 page instead of the crappy default one.
And I don't want to hear any of this "Oh but it's not released yet" crap, I've been using it CI 2.0 for almost a year. ;-)
I can think of two possibilities:
1) Edit your custom function to let it redirect your client when page's not in the db
pseudo code:
if($dbresult == null){
redirect("http://yoursite.com/"+$this->uri->segment(3));
}
2) Edit the router class of CI so it will first check if the page's in the db and if not, just continues. This may be somewhat messier as you need a db connection in your Router.php
I have a custom Joomla component and a router for building my SEF URL's for use within the site, and everything is usually shiny - internally, all of my links look and act fantastic.
I recently route a controller action that sends a list of links through email, and I've noticed that my URLs are coming out.... funky - hopefully someone can tell me why.
Usually, my router generates an internal link that looks like this:
http://localhost/Registry/calendar/265889635/Some-Long-Boring-Event
However, when I send an email and preparing the same URL through the same router I get:
http://localhost/Registry/Registry/component/calendar/569555803/Some-Long-Boring-Event
Has anybody run into this issue before?
Check your Itemid GET parameter in the URL. My guess is that it's not set in the url used in emails...
I would turn off SEF URLs temporarily and get the non-SEF version of the link you want. Compare that will the URL you are using and see what is different/missing.