Hey friends i am switching from core php to laravel framework and every thing works fine but the main problem is that my old version of site is based on this url pattern
https://m.apkleet.com/apk.php?app=garena-contra-returns
And my new laravel project url is something like this
https://m.apkleet.com/apk/garena-contra-returns
And if I change my site to laravel then it effects my seo due to this different url patterns...
my question is that how to redirect ugly url to laravel url.... Is there anything present in laravel to do this
Any help or recommendation will highly appreciated...
On your route define, just set your URL to apk.php. Something like this
Route::get('apk.php', [YourControllerClass, 'index'])->name('routeName');
And to generate the url for HTML, you need to pass app in param
route('routeName', ["app" => "garena-contra-returns"])
here is the anser of my question
Route::get('apk.php', function () {
$apk = $_GET['app'];
return redirect('apk/'.$apk);
});
Related
In phalcon 3.4 we had the below function to get the current URL,
$current_url = $this->router->getRewriteUri();
However, it seems to be that, it was dropped in version 4.0 however there is no direct corresponding function for this i could find. Can you please let me know how to change this function to adapt to version 4.0+ Or should i just use the direct way (I usually hate to mix things up) but looks like no other choice
$_SERVER['REQUEST_URI']
you can use Phalcon\Http\Request::getURI() but it uses $_SERVER['REQUEST_URI'] if your project is not on root path you may want to use $_GET['_url']
I am creating a realestate website, I want my url to be readable,
For example my site url is http://sitename/property/3, (3 represents property id)
I want to change it like this link
My question is how they are using "Residential-Apartment-Flat-in-Park-View-City-Gurgaon-4-BHK-for-Sale-spid-H13544257" this part in url.
Of course they are using id and all. How can I replace "property" with something like "residential-property-in-india" in my url and it should be changing dynamically according to search.
I hope it is clear what I want to do...
Everything is in the Yii guide
For example the folling urls config in the url manager component
array(
'posts'=>'post/list',
'post/<id:\d+>'=>'post/read',
'post/<year:\d{4}>/<title>'=>'post/read',
)
Will generate link like http://example.com/post/2004/My-title-that-can-be-long
You can tweak it to match your need,if I were you I'll read the Yii guide very carfully
At the last of rules array place this rule
'<page>'=>'someControlles/someAction',
And you will get in someControlles/someAction parameter. $page = 'any_text'. Another way to create your own UrlRule.
In Drupal 7 the css and javascript files that are compiled together and then added in the header are coming in as 'http://www.example.com/sites/all/css' and I need it to come in as 'https://www.example.com/sites/all/css'.
I've been able to achieve this by changing the baseUrl in settings.php to use https, but then it throws off our site. We are using Drupal as our CMS, and another framework as our LMS. So when the site loads the Drupal baseUrl from our LMS the address doesn't work.
Examples:
If I set baseUrl = 'https://www.example.com/cms' then the css loads properly as 'https://www.example.com/cms/sites/all/css' but then the Drupal admin site fails to load the css because the proper link from there is actually 'https://www.example.com/drupal/sites/all/css'
Same problem happens if I swap the baseUrl to = 'https://www.example.com/drupal'. This way the css doesn't load in our front end, but works properly in the Drupal admin side.
I'm wondering if there is a way to do a generic wildcard baseUrl that just says to use https like baseUrl = 'https:// %' or pulls the current url in the address bar every time to see what the generated url should look like.
I know this is very vague, but I don't know where/how else to ask.
I don't really understand your site structure using multiple subdirectories (/, /drupal, /cms) but what you could do is rewrite the resource URL's and removing the protocol.
In a custom module, implement the YOUR_MODULE_process_html hook and remove all protocols from the CSS & JS includes.
http://www.example.com/css/... will be transformed to //www.example.com/css/...
function YOUR_MODULE_process_html(&$vars)
{
foreach (array('head', 'styles', 'scripts') as $replace) {
if (!isset($vars[$replace])) {
continue;
}
$vars[$replace] = preg_replace('/(src|href|#import )(url\(|=)(")http(s?):/', '$1$2$3', $vars[$replace]);
}
}
So - I'm new to Laravel and we're using version 3.
I have a home page setup & working - say http://dev.mywebsite.com
Now I want to click a link on the page and redirect to a nice SEO friendly URL, but pass in the variables. In straight PHP this is simple - I can make http://dev.mywebsite.com/vacancies/town/page2 rewrite as http://dev.mywebsite.com/?where=town&page=2
But I can't get this to work in Laravel.
I know the full answer is to create controllers & views, but I have all the logic for the display in an included file so don't really want to change... is there any way to do this using either routes or mod-rewrite?
Thanks
Although I strongly recommend you to make a view with that file, you can still use PHP's Output Control to avoid messing with Laravel's rendering flow:
Route::get('your-nice-url-here', function() {
ob_start();
include 'your-raw-php-here';
return Response::make(ob_get_clean());
});
I'm not able to figure this out on my own so here I am asking for your help.
How do I load a website that I already made as a view in the code igniter default controller?
I put my website under a folder name site, and in the default controller I loaded the view site/index , but then in my site there are problems with the includes and redirects... I don't know why, I guess the way the site usually works with redirecting isn't compatible with code igniter style
edit: I guess I would have to turn off CI engine for this site, but I don't know why, because I would still need codeingiter to manage other parts of my application
"CodeIgniter can be told to load a default controller when a URI is not present, as will be the case when only your site root URL is requested. To specify a default controller, open your application/config/routes.php file and set this variable:
$route['default_controller'] = 'Blog';
Where Blog is the name of the controller class you want used. If you now load your main index.php file without specifying any URI segments you'll see your Hello World message by default."
http://codeigniter.com/user_guide/general/controllers.html
fragment copied from that link , you should put the controllers classname in that config, not the view
I guess it's better to choose one of these options:
Modify the existing site to a CodeIgniter site.
Keep your site separate from the CodeIgniter site, and just link between the two sites.
The way you are trying to do it seems very useless and causing a lot of extra trouble.
You can simply use the redirect function in your controller. If you supply a full URL you can go to any other page. You will, of course, leave your CI app.
redirect('http://www.example.net/page_in_external_site/');
Try using the APPPATH constant when defining the paths for the includes.
I know it's an old question, but you can try using a view template with an iframe, and you can pass the URL to the src property of the iframe. That way you can display your site inside a view, but still can't get access to the vars passed to the view from your site.
In system/Core/Loader.php change the line 141 to look like this:
$this->_ci_view_paths = array(APPPATH . 'views/' => TRUE, FCPATH => TRUE);
and to get the view is simple:
$this->load->view('application/ PATH_TO_VIEW');