I'm fixing this joomla site. It uses joomla 1.7 language filter so it adds post fixes to the url. So when i view an artcle with images, image is not displaying.
I tried htaccess rewrite rules. But it didn't work for me...
this is what i get when i copy image url.
http://domain.com/en/images/myimage.png
But when I check the code its images/myimage.png .
If i edit code to /images/myimage.png it works.
Tthis is what i try to do with htaccess too, to add a "/". Since it didn't work i guess i have to change whole url.
I don't have much knowledge in rewriting.
Can you guys help me please?
Give this a go in your .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^.*/images/(.*)$ http://%{HTTP_HOST}/images/$1 [L,R=301]
</IfModule>
This will rewrite your /en/images/... requests to /images/...
Note, this could have unexpected consequences for other URLs. I would suggest properly testing this on your own application.
The .htaccess solution only works partially for me, so I fixed this from the template's index.php file.
Inside the <head> tag, after the <jdoc:include type="head" /> code I added this code
<?php
//removed joomla autogenerated <base> tag
unset($doc->base); ?>
<base href="<?php echo JURI::root(); ?>">
Tested with Joomla 3.6.5
Related
I'm using OpenCart for my site. The icons fail to appear when you visit example.com but they do appear if you visit www.example.com.
Any ideas what is going on here?
I have just edited config.php file and removed www. and it works for naked domain but the icons do not load
// HTTP
define('HTTP_SERVER', 'http://example.com');
define('HTTP_CATALOG', 'http://example.com');
define('HTTP_IMAGE', 'http://example.com/image');
define('HTTP_ADMIN', 'http://example.com/admin');
I would redirect all non www traffic to www. This should take care of your issue with icons. It'll also prevent possible SEO issues as a result of duplicate content/pages.
If you have an apache server add a redirect to your .htaccess.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
What worked for me:
Go into the config.php file (please backup your file first) in the main directory of your OpenCart installation.
Under //HTTP (lines 5-8 for me), edit
lines:
define('HTTP_SERVER', 'http://example.com/shop/');
define('HTTP_CATALOG', 'http://example.com/shop/');
define('HTTP_IMAGE', 'http://example.com/shop/image/');
define('HTTP_ADMIN', 'http://example.com/shop/admin/');
to read:
define('HTTP_SERVER', '/shop/');
define('HTTP_CATALOG', '/shop/');
define('HTTP_IMAGE', '/shop/image/');
define('HTTP_ADMIN', '/shop/admin/');
.
Depending on your installation, I'm sure this could cause some problem somewhere I just haven't found it... yet... (maybe someone else could correct me -- I really don't mind; I like to learn).
This worked for me:
Add to .htaccess file this line: Header add Access-Control-Allow-Origin "your-domain.com"
Change "your-domain.com" required by the url.
If in our configuration file use: define ('HTTP_SERVER' 'http://example.com/);
Then place: Header add Access-Control-Allow-Origin "http://www.example.com/"
I tested this in opencart 2.0.
I'm trying to migrate my Web site from Joomla 1.5 to Joomla 2.5. After running RedMigrator I've got all articles imported in my new Web site. The URL of Joomla 2.5 articles is however different from the original one. In particular I'd like to get rid from the URL of the parent category so that it looks like
host/category/article
instead of:
host/parent-category/category/article
Is there any way to do it from the configuration or do I have to use mod_rewrite to get my URL rewrited by Apache ?
Thanks!
In my experience there's no way to do this without third-party extensions, though you might experiement with creating a hidden menu containing an item for the sub-category's blog layout.
Simply remove a url segment with .htaccess
In your .htaccess file:
RewriteEngine on
RewriteBase /
RewriteRule ^/parent-category/(.+)$ /$1 [L,QSA]
Intro
I decided to create a topic for a script that create adaptive images. I have updated this topic so I can refer. Demand a more focused on a particular answer #ChrisFerdinandi advised me to use the script Adaptive Images+. This script would do exactly do what I'm looking for.
So I was looking for a script that checked me when the website is visited on a retina screen, like an iPad or iPhone for WordPress.
Problem
I will explain at every step what I did and share my code. Before I share my code and walk-through all steps, I will post some information about my WordPress installation.
I have installed my WordPress installation in a subfolder called /wordpress. I am using a custom WP theme, that I have developed on my own. I use featured images for my portfolio items. I create them in my function.php file like add_image_size('thumbnail-portfolio', 300, 200, true);
According to the installation page of the plugin from Chris Ferdinandi, we start by changing the .htaccess file in step 1. So, what I did is past everything between the comments #START Adaptive-Images and #END Adaptive-Images immediately after RewriteEngine On.
So my entire file would like this:
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
#START Adaptive-Images
#Add any directories you wish to omit from the Adaptive-Images process on a new line.
#Omit plugins, wp-includes and wp-admin content.
RewriteCond %{REQUEST_URI} !wp-content/plugins
RewriteCond %{REQUEST_URI} !wp-includes
RewriteCond %{REQUEST_URI} !wp-admin
#Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
#to adaptive-images.php so we can select appropriately sized versions
RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php
#END Adaptive-Images
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
#END WordPress
Ok, after modifying the .htaccess file, I uploaded to the server. I update it inside the /wordpress subfolder. Fine that's done, let's go to step 2. This step I have skipped because this was an optional option.
Right step 3. I uploaded adaptive-images.php into the same directory as my .htaccess file, for clarity I have both files uploaded in the subdir. /wordpress.
Step 4. I add the cookie script right after the beginning <head> before all other scripts will run. My entire file looks like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title><?php bloginfo('name'); ?><?php wp_title('|'); ?></title>
<!-- Meta Tags -->
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<!-- Stylesheets -->
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet">
<link href="<?php bloginfo('template_directory'); ?>/css/960.css" rel="stylesheet">
<link href="<?php bloginfo('template_directory'); ?>/css/flexslider.css" rel="stylesheet">
<link href="<?php bloginfo('template_directory'); ?>/css/isotope.css" rel="stylesheet">
<!-- JavaScript -->
<script>
document.cookie='resolution='+Math.max(screen.width,screen.height)+("devicePixelRatio" in window ? ","+devicePixelRatio : ",1")+'; path=/';
</script>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/custom.js"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.flexslider.js"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.isotope.js"></script>
<script src="<?php bloginfo('template_directory'); ?>/js/jquery.isotope.min.js"></script>
<?php
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
</head>
Alright that's also done. In step 5. I have add the snippet of code to my css file.
Okay, the last step. Step 6 is testing all the stuff, here is probably the problem immediately clear. Since I have access to a mobile device retina, I decided first to look my site on that device. Unfortunately, only small resolution pictures shown, so that the image is not clear focus. I then looked as step 6 indicates that if there are really new images are created and stored/saved. There is an ai-cache folder created by the script adaptive-images.php, but this is unfortunately empty.
Something to notice, is that I have set the featured image size to the normal size and not to the retina version. So 300x200 is for default view, for retina would be the size 600x400px
What have I done?
I have checked the debug page of the script. I noticed that the cookie will be set as resolution. When I replace the line RewriteRule .(?:jpe?g|gif|png)$ adaptive-images.php in .htaccess to RewriteRule .(?:jpe?g|gif|png)$ test.png all images will be override by that one.
Error will be given after remove the comment before the error call. Every path is linking right.
I tried to change the permissions of the folder ai-cache from 755 to 777 with no results.
I've had great success with Adaptive Images, but it involves a bit of manual work. http://cferdinandi.github.io/adaptive-images/
I have found the easiest solution is to make one image -- twice the norm -- compress it, and call it on non retina displays at half its size.
See explanation here...
http://silev.org/test/Retina-resize.html
I have a slight issue. I have configured my default controller as :
c$route['default_controller'] = 'news';
so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller.
Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?
There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:
Removing the index.php file
Using the following rewrite code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also, there are many similar questions to yours, have a look at these questions from the search:
Search query on removing index.php in Codeigniter
You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite
In EE 2.2.2 having this in my htaccess file
RewriteRule ^(.*)$ /index.php/view/$1 [L]
Allowed me to rewrite domain.com/index.php/view/phone to domain.com/phone.
In EE 2.3.1 this no longer works. The problem seems to be with system\codeigniter\system\core\URI.php and I see few things has changed with this file. If I replace URI.php with the 2.2.2 version then it works again. My question is what has changed and how do I get this to work again.
Updated answer
After some time with thoughts (and testing) I've come up with an alternate solution, that might fit your need with the updated EE.
Assuming your rewrite rules are like the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Now, my suggestion is to let your view template group be the index template group.
In your index template in the view template group, you could have the following:
{exp:channel:entries channel="view_channel" require_entry="yes"}
{if no_results}
{embed="a_template_group/my_normal_frontpage"}
{/if}
<DOCTYPE html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{title}</h1>
</body>
</html>
{/exp:channel:entries}
This allows you to, without adding other rewrite rules, have your visitors go to http://example.org/phone and the view/index template will try to find the entry with the entry ID labeled 'phone'. If that entry cannot be found (the {if no_results} part) embed another template. In this case I would assume you'd like to show some sort of frontpage.
This also allows you to, under the view template group, create ordinary templates like view/create_entry which will show up, when you go to http://example.org/create_entry
This should work - and is easy customizable to fit your needs.