How to add username in URL with htaccess or with codeigniter - codeigniter

I want to add username just after domain in URL, It should have to look like this http://xx12.com/username/gallery, Can anyone please help me to resolve this issue ? Any help will be really appreciated.

You can register a route that accepts username as an argument like this:
$route['(:any)/gallery'] = 'YourController/YourMethod';

Related

Laravel URL Helper return IP address instead of Domain name

I have a problem when trying to create the Url using URL helper. I'm using Laravel 6.
$verify_url = url("/verify");
This is return the URL with the IP address instead of the domain name.
I don't know if it is a problem with the Apache server or the code.
Please help me. Thanks.
Adding this directive to Apache Virtual Host config seems to have fixed it: ProxyPreserveHost On
But a better way to use your urls is to name them in your routes/web.php. For ex:
Route::post('/verify', 'HomeController#verify')->name('verify');
and wherever you need to access to this url just use like this:
$verify_url = route('verify');

How change admin login url in Codeigniter 1?

Im using codeigniter 1 for a web system I want to change admin login url to my custom login url
current url - *http://siteUrl/admin/login*
Want to change - *http://siteUrl/adlogin*
How can I change this using config/router.php
thanks.
make route in config/routes.php
$route['siteUrl/adlogin']='controllername/methodname';
You can create routes for Your New URL Like :
URL:
application_url/application/config/routes.php
$route['adlogin'] = 'admin/login;
Please try this solution for your problem.
Use That on Route Without parameter Pass
$route['adlogin'] = 'admin/login';
With parameter Use This..
$route['adlogin/(:any)'] = 'admin/login/$1';

How the Url path from file path name to another name in laravel

Fins below the route code.
Route::get('clientlayout.main.index','InvoiceTicketController#show');
Route::get('clientlayout.main.mydomains','InvoiceTicketController#set');
When I run these routes I'm getting the url as
http://localhost:8000/clientlayout.main.index and
http://localhost:8000/clientlayout.main.mydomains.
I want my Url to be changed as follows: http://localhost:8000/index and http://localhost:8000/mydomains.
Suggest me a solution for changing the route to rectify this issue.
Route::get('/index','InvoiceTicketController#show');
Route::get('/mydomains','InvoiceTicketController#set');
for named routes you can use like this way
Route::get('/index','InvoiceTicketController#show')->name('clientlayout.main.index');
for more details follow
https://laravel.com/docs/5.6/routing#named-routes
You should try the route.
Route::get('/clientlayout/main/index','InvoiceTicketController#show');
Route::get('/clientlayout/main/mydomains','InvoiceTicketController#set');
Url is making
http://localhost:8000/clientlayout/main/index
http://localhost:8000/clientlayout/main/mydomains
Or You Should try
Route::get('/index','InvoiceTicketController#show');
Route::get('/mydomains','InvoiceTicketController#set');
Then Url is making
http://localhost:8000/index
http://localhost:8000/mydomains

response.sendRedirect(url) in Spring MVC controller to external host actually redirects to local host

I ve done some researches but couldn't find any question or answer that could help me,
so my probleme is as below :
I have a controller that redirects to an external link :
#controller("person")
publi class PersonController(){
#RequestMapping(value="redirect",method=RequestMethod.POST)
public String redirectToExternalLink(params...){
String url = "https://externalHost.com/doSomthing";
response.sendRedirect(url);
}
}
after going through this method, I find my self face to a 404 error Page not Found, when I check the link I ve been redrected to I find :
www.mydomainName.com/doSomthing
As you can see, the external domain name is replaced by mine, I ve tried also this :
response.setHeader("Location",url);
response.sendRedirect(url);
same issue.
is it a configuration that I should do on tomcat ? or there is a way to solve it ?
thanks
Your code
response.sendRedirect(url);
is correct. However, I would double check the url redirected to. I would also run the code in debug mode and check if
response.sendRedirect(url);
is executed in the first place.
Please refer to this question, Redirect to an external URL from controller action in Spring MVC.
If you encounter the common problem.
For my case, it was a network configurations issue (URL rewriting).

PHP session login different for url with www and without www?

I am debugging on session login, when i am login to www.domainname.com the session will be only set for with www.
When i am going to url domain.com, session login is ignored, and i will be prompted to login form again.
I have set session cookie_domain also, but not working.
Any one can help me? why?
I know this question is as old as "Who came first? The egg or the chicken?"
I had a lot of trouble about this issue.
But... if you're using php I've found a solution:
In your login script insert in the first line
<?php
session_set_cookie_params(0, '/', 'www.yourdomain.com');
session_start()
?>
or you can try yoursubdomain.yourdomain.com instead www.yourdomain.com.
It works for me. Hope it help other users too.
I highly recommend redirecting users to the canonical version of the site (probably the www.example.com domain). Look around, you'll notice that most sites do exactly this for consistency (including SO; see what happens when you go to www.stackoverflow.com).
Have you tried setting the session domain to ".example.com"?:
$lifetime = 0;
$path = '/';
$domain = '.yourdomain.com';
session_set_cookie_params($lifetime, $path, $domain);
Note the dot in the beginning of the $domain string variable.
Check the reference of the function here.

Resources