How can i write htaccess for codeigniter project below is my htaccess code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.generaltechuae\.com
RewriteRule ^(.*)$ http://generaltechuae.com/%1/$1 [L,NC,QSA]
my domain address is http://www.generaltechuae.com/,
I can't access inner pages by http://www.generaltechuae.com/index.php/aboutus.
But i can access the about us page by http://www.generaltechuae.com/generaltechuae/index.php/aboutus
and also enclosed my config parameters
$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
why generaltechuae is repeat after the domain address
Can someone help me how to solve this problem?
Thanks.
First solution
It is because you have uploaded all the websites files in your folder name: "generaltechuae" .
Currently, your website has base URL:
http://www.generaltechuae.com/generaltechuae/
You have to place all your files in root folder {public_html} to your server.After it your website base url will be:
http://www.generaltechuae.com/
So your problem will be resolved.
Second Solution
You can have another solution as you can right an .httpaccess rule, which will ignore your folder name.
Related
I have an application whose codebase is deployed inside a folder shop . The URL to the main application is http://myapp/shop/.
One of the links on my page reads
http://myapp/shop/website-design/design-urself.php
which I want to redirect to http://myapp/shop/website-design/index.php
The rule which I am using in my .htaccess file is :
RewriteEngine On
RewriteBase /
RewriteRule ^/website-design/design-urself.php /website-design/index.php [R=301]
But the link is wrongly being getting redirected to http://myapp/website-design/index.php
I tried by removing the leading slash (/) from the urls as :
RewriteRule ^website-design/design-urself.php website-design/index.php [R=301]
but still it doesn't work.
I can understand that probably changing the RewriteBase to shop will solve my problem.
However , the thing here is - going further, the folder name ("shop" in my case) can change . So , in that case I have to again go and modify the .htaccess , which is not desirable.
What is the appropriate RewriteRule I should use in this case?
UPDATE : I have my .htaccess file located at my document root , i.e, inside the folder shop and outside of all other folders residing inside shop.
My Website (opencart) works great on mywebsite.com but i got problems when trying www.mywebsite.com,
eg: icons on header and products disappear.
I tried to add a line on config.php:
<?php
// HTTP
define('HTTP_SERVER','http://mywebsite.com/');
// HTTPS
define('HTTPS_SERVER', 'http://mywebsite.com//public_html/');
// DIR
define('DIR_APPLICATION', '/home/XXXX/public_html/catalog/');
define('DIR_SYSTEM', '/home/XXXX/public_html/system/');
define('DIR_DATABASE', '/home/XXXX/public_html/system/database/');
define('DIR_LANGUAGE', '/home/XXXX/public_html/language/');
define('DIR_TEMPLATE', '/home/XXXX/public_html/view/template/');
define('DIR_CONFIG', '/home/XXXX/public_html/system/config/');
define('DIR_IMAGE', '/home/XXXX/public_html/image/');
define('DIR_CACHE', '/home/XXXX/public_html/system/cache/');
define('DIR_DOWNLOAD', '/home/XXXX/public_html/download/');
define('DIR_LOGS', '/home/XXXX/public_html/system/logs/');
// DB
define('DB_DRIVER', 'mysql');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'XXXX_com1');
define('DB_PASSWORD', 'XXXXXXXXX');
define('DB_DATABASE', 'XXXX_com1');
define('DB_PREFIX', 'oc_');?>
define('HTTP_SERVER','http://www.mywebsite.com/');
under
define('HTTP_SERVER','http://mywebsite.com/');
nothing happened.
i'm beginner on opencart, How can I solve this ?
Opencart only works over 1 url,
You have never been a opencart website working with two different url, to fix that your will have to include the following in your htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourDomain\.com
RewriteRule (.*) http://yourDomain.com/$1 [R=301,L]
This code redirect, all urls with www to urls without www.
This fix your problem.
The source
I have this url:
http://localhost/search/
This returns me this file:
http://localhost/search.html
Now I want the urls with this structure:
http://localhost/search/([^/]+)/([^/]+)/([^/]+)/?
will redirect me to the search.html file too. But without changing the url.
For example with this urls:
http://localhost/search/women/23/shoes/
http://localhost/search/
http://localhost/search/man/45/shirt/
would return the same file:
http://localhost/search.html
Note: the urls of man and women does not has any existing path in the server.
Any advice or help would be appreciated. If you need more info, let me know and I'll edit the post.
RewriteEngine on
RewriteRule ^search/ /search.html
Will just work fine. Unless you explicitly request an external redirect, a RewriteRule on the same domain will not do one, thus not changing the URL visible in the browser.
if you don't need the rest of url then you can use this
RewriteEngine On
RewriteRule ^search/(.*)$ /search.html [L]
if you need to other parameters of url then let me know
edited version, Niels Keurentjes has a point if you don't need the rest of url
RewriteEngine On
RewriteRule ^search /search.html
I'm trying install my codeigniter application in a sub folder: http://website.com/sub_folder
And I want that this site is accessible through: http://website.com/
I have the following info in my application/config.php file for the base url: $config['base_url'] = 'http://website.com/sub_folder';
This is my .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|assets|favicon\.gif|robots\.txt)
RewriteRule ^(.*)$ /sub_folder/index.php/$1 [L]
The problem is that when I change the $config['base_url'] to access my asset files, like css etc al my other links using $base_url() point to : http://website.com/sub_folder too instead of http://website.com/
If I understand what you want to achieve, you're doing it wrong, simply place index.php file in your root folder and your application to the sub-folder.
Change system and application paths in index.php to where exactly they are located and you're done.
$system_path = 'subfolder/system';
$application_folder = 'subfolder/applications';
In any case, if it's possible, consider moving application and system folders out of the root directory as it will cover hundreds of potential security holes.
Two things:
Firstly - I have version 2 of a website located in a folder named v2, and I want to redirect any traffic that is NOT a child of the v2 folder, to www.example.com/v2
The old site located in the root was created in iWeb and has a LOT of subfolders and sub-subfolders.
So:
www.example.com/v2 = New site
www.example.com/Page.html
www.example.com/category/Page.html
ww.example.com/category/subcategory/Page.html = All generic examples of what I need to redirect.
Secondly, and I don't know if this is possible, I want to hide /v2/ in the URL, so that visitors will just see www.example.com/page even though they are actually on www.example.com/v2/page
Links are hardcoded to the v2 folder, like so <a href="v2/contact.html">
Any help is MOST appreciated. I've spent hours trying to figure this out, but I'm only just learning about htaccess and regular expressions, and am totally confused.
Thanks so much!
RewriteCond %{REQUEST_URI} !^v2/
RewriteRule ^(.*)$ v2/$1 [L]
rewrite everything by including v2 before it .
RewriteRule ^(.*)$ v2/$1 [L]
www.example.com/Page.html should now be processed as /v2/Page.html
You should not include v2/ in the url being sent to the user.
it would then become v2/v2/