I'm working on an open cart site and I was editing the .htaccess file to allow for SEO friendly URLs.
The system is in a subdirectory if that helps.
Some of the work was done prior to me taking on the job by another developer who isnt providing any help at the moment. (I've took out the actual url as I can only currently post a limited amount of links per post)
RedirectMatch permanent ^/$ http://www.furnishingsdirect.co.uk/new
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.furnishingsdirect\.co\.uk [NC]
RewriteRule (.*) http://www.furnishingsdirect.co.uk/$1 [R=301,L]
RewriteEngine on
Options +FollowSymLinks#RewriteCond %{THE_REQUEST} ^.*/index\.php [NC]
RewriteRule ^(.*)index.php$ http://www.furnishingsdirect.co.uk/$1 [R=301,L]
The second .htaccess file contains:
Options +FollowSymlinks
Options -Indexes
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteBase /new/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Whenever I try to access the website through the url
http://www.furnishingsdirect.co.uk
or
http://www.furnishingsdirect.co.uk/new/
It states that "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."
I'm positive that this code was fine earlier till I altered the web forwarding through 123 reg. I forwarded the furnishing direct domain so that it always directed users to the directory with the shop system in it. I think that is what has cause the issue, 123 reg says it will take some time for the site to adjust but Im unsure. Can anyone help shed some light on this situation? any help would be appreciated.
The DNS for this domain is pointing to web hosting, it was originally pointing to the 123 reg holding/forwarding service.
your problem probably is in the config.php file, if this constant was defined to your root, and your .htaccess redirect to your /new, you get into a loop. look at this on your config.php file:
// HTTP
define('HTTP_SERVER', 'http://www.furnishingsdirect.co.uk/');
and change to '/new'.
First of all if you have 2 .htaccess files, please use the second one as it is closer to the default one the first has many changes to it. Or better yet if you find extensive trouble download a new .htaccess from the Opencart site (for the appropriate version ofc.)
Secondly check your config.php that
define('HTTP_SERVER', 'http://domain/');
and
define('HTTPS_SERVER', 'http://domain/');
are set correctly.
Except from defining the base there should be no other need for your cart to be functional, if you want to add custom .htaccess code please add at the end of the .htaccess files (that is the way i use some domain redirects for example)
Related
I have WAMP server where there are 5 projects hosted 192.168.0.10 as
192.168.0.10:80
192.168.0.10:81
192.168.0.10:82
192.168.0.10:83
192.168.0.10:84
now I have changed and moved all these projects to new server 192.168.0.11 as
192.168.0.11:80
192.168.0.11:81
192.168.0.11:82
192.168.0.11:83
192.168.0.11:84
I want if someone still access
192.168.0.10:80/* it should be redirected to 192.168.0.11:80/*
what will be best solution?
for time being I can keep old server and place there some file e.g. .htaccess for redirection
I tried below in .htaccess file at old server but still it is not redirecting
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
#code below is for redirtect
RewriteEngine On
RewriteCond %{HTTP_HOST} ^192.168.0.10$
RewriteRule ^(.*)$ http://192.168.0.11$1 [R=301,L]
</IfModule>
With your shown samples, could you please try following. Please make sure to place these rules always at top of your htaccess file. Values and etc are totally based on shown samples by original poster here.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^192\.168\.0\.10:81$
RewriteRule ^ http://192.168.0.11:%{SERVER_PORT}%{REQUEST_URI} [NE,R=301,L]
NOTE: As per OP's suggestion, edited line with port 81 here in condition line.
I found this little trick http://css-tricks.com/snippets/htaccess/301-redirects/ to redirect my old Wordpress domain to my new domain with the path included. I run a test on my local copy and everything works fine. When I log in to the cpanel of the old domain and try it though it gives me some bad results.
Here is the code I used for both my local and live copy ...
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Redirect 301 / http://newsite.com/
Here's what the results look like http://www.cuponsmercado.com.br/lojas/. It looks to be calling the new domain (based on the Google Chrome status at the bottom left) but it just shows the old domain with broken HTML/CSS. Any Ideas?
UPDATE:
I was mistakenly editing the same domain when I thought I was editing both. Both were hosted on the same hosting account but displayed separate cPanel URLs leading to the confusion. There was a chance one .htaccess was conflicting with the other domain as well.
Make this as first rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?cuponsmercado\.com\.br$ [NC]
RewriteRule ^ http://www.cuponsdemercado.com.br%{REQUEST_URI} [L,NE,R=302]
You need to stick with mod_rewrite because a request will get both modules applied (Redirect is mod_alias):
Above your # BEGIN WordPress section add:
RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301]
Additionally, you can use mod_alias and get rid of all the old wordpress rules if you are simply moving your site from one server to another.
I am trying to change the url that is displayed in the address bar from mysite.com/blog/wedding-hair/ to mysite.com/services/wedding-hair/ using .htaccess.
Using answers from:
https://stackoverflow.com/questions/8713319/assigning-different-name-to-existing-folder-in-url-in-htaccess
rewrite a folder name using .htaccess
Replace directory name in url with another name
I added to the .htaccess file. Here is the .htaccess file, I added the last rewrite rule:
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com" [R=301]
RewriteRule ^blog/(.*)$ /services/$1 [L]
the non-www redirect works but not the blog-services rewrite. I thought maybe I had the directory names reversed but changing them around doesn't work either. I have tried adding and removing /'s around the directory names in all of the different combinations. I tried adding
RewriteCond %{THE_REQUEST} ^GET\ /blog/
before my RewriteRule. Nothing I Have tried has worked, the displayed url remains mysite.com/blog/wedding-hair/
I am sure this is pretty straight forward for someone but I am unable to get this correct. Any help would be appreciated.
When I was working on this yesterday I didn't think about the fact that the blog directory is a WordPress install. Here is the .htaccess file that is in the blog directory:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
I have tried adding my RewriteRule in this file but still no joy.
The problem here is that RewriteRule ^blog/(.*)$ /services/$1 [L] internally rewrites the URI, so that the browser doesn't know it's happening, this happens entirely on the server's end. If you want the browser to actually load a different URL, you need to use the R flag like you are in your www redirect, though it's only redirecting requests to root. If you want it to redirect everything to include the "www", you want something like this:
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Then to redirect "blog" to "services", just add the R flag (or R=301 if you want the redirect to be permanent).
RewriteRule ^blog/(.*)$ /services/$1 [L,R]
And, if for whatever reason your content isn't actually at /blog/, you need to internally rewrite it back
RewriteCond %{THE_REQUEST} ^GET\ /services/
RewriteRule ^services/(.*)$ /blog/$1 [L]
But this is only if your content is really at /blog/ but you only want to make it appear that it's at /services/.
Actually, in such case, as you have a specific field in Wordpress options to handle the display of a different url, it CAN'T work with .htaccess is the WordPress rules are executed at the end.
And it would be much simpler to use the field "Site Address (URL)" in the General Settings, and enter "mysite.com/services/"
If you don't do that, in spite of your .htaccess, the WP internal rewriting will use you installation repertory
Ok, so I have to do some work on a client site - and for some reason, they have both the www. subdomain and the empty subdomain in use, with different websites. They do NOT want this.
They want the www. subdomain ONLY (that is, they want the empty subdomain to redirect to www.)
That's how it is set up in Wordpress, supposedly.
Here's my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^(.*)(\.htm|\.html)$ /contact [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#php_flag display_errors on
#php_value error_reporting 8191
Can anyone interpret this? (I am not very familiar with .htaccess files - anyone who has any resources on them would be helpful). How do I make it so that anyone going to http://examplesite.com goes to http://www.examplesite.com, for example.
How are there two different websites on the same domain? I'm looking in the public_html folder and there appears to be NO reference to the other site at all - nothing, no files, nada.
To force using www subdomain, you can add this code :
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*) http://www.domain.com/$1 [QSA,L,R=301]
Here is what those line does :
Check the HTTP_HOST, which must be domain.com
Take the current request and add it after www.domain.com/ ($1 represents the request caught)
Use the generated url as a 301 redirection (permanent redirection) with [R=301] tag
Doesn't read next rules if this one is caught, with [L] tag
Forward GET datas, with [QSA] tag.
You must put this code after those two lines :
RewriteEngine On
RewriteBase /
Which set the Rewrite engine on, and define the base url.
Be careful : redirection doesn't forward POST datas. Be sure alwayse use www subdomain in your code (this can easily be done using a centralized base_url).
Have a look here to understand better htaccess files.
I have a list of URLs such as,
http://www.mywebsite.com/page.php?genus=A_GENUS&species=A_SPECIES&id=12345.
I would like to write a .htaccess which permanently redirects visits to this form of URL to the following URL,
http://www.mywebsite.com/species/A_GENUS/A_SPECIES.
Is it possible to do this without having to manually list each species in the database?
I've tried to look it up but my head is in WordPress-Custom-Post-Type land and as such my brain isn't functioning properly. Any help would be greatly appreciated.
EDIT: Clarification
Currently my .htaccess is completely empty. I am re-writing my website to use an entirely new CMS and this new URL format. The old URL format will cease to exist but all of the information will still be used.
We are quite highly ranked for a lot of species on Google and I would like visitors from there to be able to view the information they require despite the URL format changing.
These changes haven't occurred yet (still using a Sandbox environment for the new version of the site) and I'd like to make the URL changes just before I "go live" with the new version.
EDIT 2: New site .htaccess
The contents of the new site's .htaccess looks like this in its entirety:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sandboxfolder/index.php [L]
</IfModule>
# END WordPress
EDIT for Garmen's answer
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteCond %{QUERY_STRING} genus=([a-zA-Z0-9-]+)&species=([a-zA-Z0-9-]+)
RewriteRule ^profile.php$ /species/%1/%2 [R=302]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sandboxfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sandboxfolder/index.php [L]
</IfModule>
# END WordPress
Not sure if I've used RewriteBase correctly there, but it doesn't appear to function with or without it.
Regards,
RewriteEngine On
RewriteCond %{QUERY_STRING} genus=([a-zA-Z0-9-]+)&species=([a-zA-Z0-9-]+)
RewriteRule ^page.php$ /species/%1/%2? [L,R=302]
This one assumes a very specific order of query string parameters. So be warned. Also it assumes the names only contains plain letters, numbers, or dashes.
Change 302 to 301 when you are done testing. I used 302 because 301's are aggressively cached by browsers, making debugging very difficult.
EDIT: You should add this above the other rewrite rules you have, or it will not work.
EDIT 2: added a ? at the end to remove the querystring. And L flag to prevent further execution.