Redirect url using htaccess "/" - codeigniter

I have an issue on my website. The issue is that whenever I visit my website with this url: http://wowriters.com/assignment-writing-service
It is fine.
But whenever I visit my website with this url: http://wowriters.com/assignment-writing-service/
My website layout broken.
Kindly help me to handle it using "htaccess" or any other solution in "Codeigniter".
Thanks in advance.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

You can use:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+)/$ $1 [L,R=301]

Related

How to convert .htaccess to web.config?

I am realy lost here. I am used to work with linux server so I use .htaccess
Now I need to develop a project in windows server and I need to use some rewrite rules, etc. So I need to set the web.config file.
So I need help to convert my .htaccess rules to web.config
This are the rules:
RewriteEngine On
RewriteRule ^box/camp(.+)?/?$ /_box/access_box_files/camp$1
RewriteRule ^box/merchant(.+)?/?$ /box/access_box_files/merchant$1
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url_tab=$1 [L,QSA]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
UPDATE
RewriteRule ^box/camp(.+)?/?$ /_box/access_box_files/camp$1
In this case I need that whenever the URL is "/box/camp" there is access to "/_box/access_box_files/cam" and that all the information that comes in front of "(.+)?" "$1" is included. Without changing the URL in the browser, or forwarding the user.
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url_tab=$1 [L,QSA]
In this case, any information that comes in the URL must be collected in a variable.
For example:
https:// website dot com/tab1/tab2/tab3
I will get the information in: $_GET['url_tab'] which would have the information: "tab1/tab2/tab3".
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
In this case it is to force the URL to be loaded with https.
Thank you all very much.

Laravel pagination broke on GoDaddy Production server

I have just uploaded my laravel application to my godaddy server and everything works apart from my 'search' functionality and 'pagination' which I presume are related to the same problem, being the URI. I thought maybe it is a .htaccess problem but if so I am unaware of how I can rectify this?
I tried deleting the config cache and it did not solve it.
.htaccess in public_html
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
.htaccess in laravel root
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I am using 'variable->links()' to output the pagination links with 'paginate(11).
I hope somebody can be of any assistance which would be highly appreciated.
I adapted my research skills and managed to find a fix using the .htaccess found
https://stackoverflow.com/questions/22403519/laravel-4-pagination-not-working-links-are-ok-but-shows-all-results-in-each-page here.

Apache2 multiple folders

I have following structure of my project
root
ra-cms-admin
dist
ra-cms-admin
index.html
...
ra-cms-public-and-api
public
index.php
...
ra-cms-admin is the single page application. I need when a user goes to / I want to redirect to ra-cms-public-and-api->public->index.php, and when the user goes to /admin (or /admin/something...) I want to redirect to single ra-cms-admin->dist->ra-cms-admin->index.html else I want to redirect always to to ra-cms-public-and-api->public->index.php (/something...).
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin ra-cms-admin/dist/index.html [L]
RewriteRule ^ ra-cms-public-and-api/public/index.php [L]
</IfModule>
This app project is on my server in test folder.So when you want to access this app, you need to go localhost/test , but I have problem with admin section, when i put localhost/admin I am redirected still to public section... Any idea? According to https://htaccess.madewithlove.be/ my solutions should work, admin is matched...
Move UP, or use RewriteCond.
RewriteEngine On
RewriteRule ^admin/(.+)$ /ra-cms-admin/dist/%1 [L]
Can you try?
RewriteRule ^admin ra-cms-admin/dist/ra-cms-admin/index.html [R=301,L]

Codeigniter error 404 on production after set_flashdata

I'm using CI on my project, when I moved it on production server, I saw the error "404 page not found" when calling $this->session->set_flashdata. This error is preserved when I requested any page until I cleared the cookies. This error repeats after call "set_flashdata" again.
function _set_success($message)
{
$this->session->set_flashdata('is_db_msg', 1);
$this->session->set_flashdata('db_msg', $message);;
}
$result = $this->page_model->edit_page($page_name, $this->_get_data_array());
$result ? $this->_set_success('OK') : $this->_set_error(DB_ERROR);
redirect(BASEURL.'admin/pages');
// server 404 (on any page) after redirect
BASEURL it's constant: DEFINE('http://mysite.com');
Also I'm using this .htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^(index\.php/?)?(.*[^/])/?$ http://mysite.com/$2 [L,R=301]
RewriteCond %{HTTP_HOST} ^www [NC]
RewriteRule ^$ http://mysite.com [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(index\.php/?)?(.+)/$ /$2 [L,R=301]
RewriteCond %{ENV:REDIRECT_FINISH} ^$
RewriteRule ^index\.php/(.*)$ $1 [L,R=301]
RewriteRule ^(main/index(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^([^/]*)/index/?$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^(system|application).*
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,E=FINISH:END]
Please, help and sorry for my bad english.
You should use following for redirecting:
redirect('admin/pages');
or
redirect(base_url().'index.php/admin/pages');
or
DEFINE('BASEURL','http://mysite.com')
redirect(BASEURL.'index.php/admin/pages');

CodeIgniter URL rewrite not working

I am trying to redirect url in CodeIgniter framework with www.hostname.com/crm/some/url to www.hostname.com/index.php?/some/url
I wrote following rule in my .htacess
RewriteEngine on
RewriteRule ^crm(.*)$ index.php?/$1 [L]
When i try this in browser, i get page not found 404 from codeIngnitor. But if add [R] flag in the redirect rules, it works proper and i could see the new url as expected after the change.
I tried apache rewrite log. Everything looks proper. I have no what URL the CodeIgniter frame sees after rewrite. Any help is appreciated.
Is there a reason you're not using the typical Codeigniter .htaccess?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
You can follow this, Do this code copy and paste in your .htaccess file. I think
it will help you.
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|uploads|themes|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

Resources